当前位置: 首页>>代码示例>>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;未经允许,请勿转载。