當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Meteor.users.update方法代碼示例

本文整理匯總了TypeScript中meteor/meteor.Meteor.users.update方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Meteor.users.update方法的具體用法?TypeScript Meteor.users.update怎麽用?TypeScript Meteor.users.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在meteor/meteor.Meteor.users的用法示例。


在下文中一共展示了Meteor.users.update方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

Meteor.startup(function () {

  if (Meteor.users.find().fetch().length === 0) 
  {
    var users = [
        {name:"Test1",email:"test1@example.com",roles:[]},
        {name:"Test2",email:"test2@example.com",roles:[]},
        {name:"Test3",email:"test3@example.com",roles:[]},
        {name:"Admin",email:"admin@example.com",roles:['admin']}
      ];

	for (var i = 0; i < users.length; i++) 
	{      
      console.log(users[i]);
      var id = Accounts.createUser({
        email: users[i].email,
        password: "password",
        profile: { name: users[i].name }
      });
      // email verification
      Meteor.users.update({_id: id}, {$set:{'emails.0.verified': true}});
      Roles.addUsersToRoles(id, users[i].roles); 
    }
  }

});
開發者ID:Feldor,項目名稱:society,代碼行數:26,代碼來源:main.ts

示例2: Promise

    return new Promise((resolve, reject) => {
        Meteor.users.update(
            {
                opponents: {
                    $elemMatch: {
                        poemId: id
                    }
                }
            },
            {
                $pull: {
                    opponents: {
                        poemId: id
                    }
                }
            },
            {
                multi: true
            }, Meteor.bindEnvironment((err, id) => {
                if (err || !Boolean(id)) {
                    return reject(err);
                }

                return resolve(id);
            })
        );
    })
開發者ID:Puzochacha,項目名稱:rhy,代碼行數:27,代碼來源:game.ts

示例3: Promise

    return new Promise((resolve, reject) => {
        if (!userId) {
            return reject('user is not authorized');
        }

        if (!isLiked) {
            setter = {
                $push: {
                    liked: {
                        userId: userId,
                        poemId: poemId
                    }
                }
            }
        } else {
            setter = {
                $pull: {
                    liked: {
                        userId: userId,
                        poemId: poemId
                    }
                },
                $push: {
                    disliked: {
                        userId: userId,
                        poemId: poemId
                    }
                }
            }
        }

        return Meteor.users.update({
                _id: userId
            },
            setter,
            (err, id) => {
                if (err || !Boolean(id)) {
                    return reject(err);
                }

                return resolve(id);
            }
        )
    });
開發者ID:Puzochacha,項目名稱:rhy,代碼行數:44,代碼來源:user.ts

示例4: keys

Accounts.onLogin(({ user }) => {
    const SKIP_SERVICES = ['resume'];
    const WHITELIST_SERVICES = ['facebook'];

    if (!user.services) {
        return;
    }

    const verifiedEmails = [];


    if (user.verified_emails) {
        user.verified_emails
            .filter(Boolean)
            .forEach((email) => verifiedEmails.push(email));
    }

    keys(user.services)
        .filter((service) => !contains(SKIP_SERVICES, service))
        .forEach((serviceName) => {
            const service = user.services[serviceName];

            if (contains(WHITELIST_SERVICES, serviceName)) {
                verifiedEmails.push(service.email);
            }


            if (service.emails) {
                Object.keys(service.emails)
                    .map((email: string) => service.emails[email] as IServiceEmail)
                    .filter(({ verified }) => verified)
                    .map(({ email }) => email)
                    .forEach((email) => verifiedEmails.push(email));
            }

        });

    Meteor.users.update(user._id, {
        $set: { verified_emails: unique(verifiedEmails) }
    });
});
開發者ID:kucharskimaciej,項目名稱:bullet-journal,代碼行數:41,代碼來源:on_login.ts

示例5:

    Meteor.loginWithPassword(username, password, (error) => {
      if (typeof error !== 'undefined') {
        this.swalService.swal('Warning', error.reason, 'error');
      } else {
        var user = Meteor.users.findOne(Meteor.userId());

        Meteor.users.update(
          {
            _id: user._id
          }, {
            $set: {
              profile: {
                name: user.profile.name,
                status: 'online'
              }
            }
          }
        );

        this.swalService.swal('Info', 'anda berhasil login', 'success');
        window.location.href = '/post';
      }
    });
開發者ID:RizkiMufrizal,項目名稱:Socially-Angular2-Meteor,代碼行數:23,代碼來源:login-form.ts

示例6: initMethods

export function initMethods() {
  Meteor.methods({
    addChat(receiverId: string): void {
      if (!this.userId) throw new Meteor.Error('unauthorized',
        'User must be logged-in to create a new chat');

      check(receiverId, nonEmptyString);

      if (receiverId == this.userId) throw new Meteor.Error('illegal-receiver',
        'Receiver must be different than the current logged in user');

      const chatExists = !!Chats.collection.find({
        memberIds: {$all: [this.userId, receiverId]}
      }).count();

      if (chatExists) throw new Meteor.Error('chat-exists',
        'Chat already exists');

      const chat = {
        memberIds: [this.userId, receiverId]
      };

      Chats.insert(chat);
    },
    removeChat(chatId: string): void {
      if (!this.userId) throw new Meteor.Error('unauthorized',
        'User must be logged-in to remove chat');

      check(chatId, nonEmptyString);

      const chatExists = !!Chats.collection.find(chatId).count();

      if (!chatExists) throw new Meteor.Error('chat-not-exists',
        'Chat doesn\'t exist');

      Messages.remove({chatId});
      Chats.remove(chatId);
    },
    updateProfile(profile: Profile): void {
      if (!this.userId) throw new Meteor.Error('unauthorized',
        'User must be logged-in to create a new chat');

      check(profile, {
        name: nonEmptyString,
        picture: nonEmptyString
      });

      Meteor.users.update(this.userId, {
        $set: {profile}
      });
    },
    addMessage(chatId: string, content: string) {
      if (!this.userId) throw new Meteor.Error('unauthorized',
        'User must be logged-in to create a new chat');

      check(chatId, nonEmptyString);
      check(content, nonEmptyString);

      const chatExists = !!Chats.collection.find(chatId).count();

      if (!chatExists) throw new Meteor.Error('chat-not-exists',
        'Chat doesn\'t exist');

      return {
        messageId: Messages.collection.insert({
          senderId: this.userId,
          chatId: chatId,
          content: content,
          createdAt: new Date()
        })
      }
    }
  });
}
開發者ID:pro-to-tip,項目名稱:pro-to-tip.github.io,代碼行數:74,代碼來源:methods.ts

示例7: function

//                 console.dir(options)
//     console.log("searchString" + searchString)
//   return Meteor.users.find(selector , options);
// });


Meteor.methods({

    'users.insert'(user) {
        Meteor.users.insert(user);
    },
    'users.remove'(userId) {
        Meteor.users.remove(userId);
    },
    'users.update'(userId, action) {
        Meteor.users.update(userId, action);
    },
    'users.getUsers'() {
        console.log('on server, Meteor.users.find({}) called');
        return Meteor.users.find({}).fetch();
    },

});

Meteor.users.allow({
    insert: function () {
        return true;
    },
    update: function () {
        return true;
    },
開發者ID:admirkb,項目名稱:ads,代碼行數:31,代碼來源:users.ts

示例8:

 commonAppUpdateUser:function (user: IUser) {
   if (user._id !== this.userId) {
     throw new Meteor.Error("403-profile-update-for-wrong-user", "Only the user can update his/her own profile.");
   }
   return Meteor.users.update({_id: user._id}, {$set: user});  // TODO: Check into whether this has the necessary dupe checks, or if they need to be done here
 }
開發者ID:kokokenada,項目名稱:for-real-cards,代碼行數:6,代碼來源:user.model.ts


注:本文中的meteor/meteor.Meteor.users.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。