当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Meteor.users.remove方法代码示例

本文整理汇总了TypeScript中meteor/meteor.Meteor.users.remove方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Meteor.users.remove方法的具体用法?TypeScript Meteor.users.remove怎么用?TypeScript Meteor.users.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meteor/meteor.Meteor.users的用法示例。


在下文中一共展示了Meteor.users.remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: addTestUser

function addTestUser(username:string, email:string, role:string) {
  let existsUser:any = Accounts.findUserByEmail(email) ? true : false;
  if (existsUser) {
    Meteor.users.remove({_id: existsUser._id});
  }
  const password = "1234";
  log.info("Created Username:" + username + ", email: " + email +", password:" + password + ", role:" + role );
  var user = Accounts.createUser({username: username, email: email, password: password});
  Roles.addUsersToRoles(user, [role]);
}
开发者ID:kokokenada,项目名称:for-real-cards,代码行数:10,代码来源:user.model.ts

示例2: extend

Accounts.onCreateUser((options, user) => {
    let currentService, loginEmail;

    user.profile = extend({}, user.profile, options.profile);

    if (user.services) {
        currentService = first(keys(user.services));
        loginEmail = user.services[currentService].email;
    }

    const originalUser = Meteor.users.findOne({'verified_emails': loginEmail});

    if (!originalUser) {
        return user;
    }

    // remove old account
    try {
        Meteor.users.remove(originalUser._id);
    } catch (e) {
        throw new Meteor.Error(500, e.toString());
    }


    // add the services to the new account
    for (let service of REGISTERED_SERVICES) {
        if (originalUser.services[service]) {
            user.services[service] = originalUser.services[service];
        }
    }

    // update posts
    Posts.update({ author: originalUser._id }, { $set: { author: user._id }}, { multi: true });
    user.profile = extend({}, originalUser.profile, user.profile, options.profile);

    return user;
});
开发者ID:kucharskimaciej,项目名称:bullet-journal,代码行数:37,代码来源:on_create_user.ts

示例3: if

Accounts.onCreateUser((options, user) => {
  // Grab the default profile object if it exists.
  const profile = (options.profile !== undefined) ? options.profile : user.profile;
  let service;
  let address;

  if (user.services) {
    for (const serviceName in user.services) {
      if (Object.hasOwnProperty.call(user.services, serviceName)) {
        service = user.services[serviceName];
        address = (service.email) ? service.email : false;
        if (!address) {
          const emails = (serviceName === 'password') ? user.emails : service.emails;
          for (let i = 0; i < emails.length; i++) {
            const email = emails[i];
            if (email.primary) {
              address = email.address;
            }
          }
        }

        if (service.username && !profile.name) {
          profile.name = service.username;
        }
        // Create or merge the profiles if needed.
        if (!user.profile && profile) {
          user.profile = profile;
        } else if (profile) {
          user.profile = Object.assign(profile, user.profile);
        }

        if (address) {
          const _emails = user.emails || [];
          _emails.push({ address });
          user.emails = _emails;
        } else {
          return user;
        }
      }
    }

    // BEWARE!!! Hackery below
    // See if any existing user has this email address, otherwise create new
    // From http://meteorpedia.com/read/Merging_OAuth_accounts
    const existingUser = Meteor.users.findOne({ 'emails.address': address });
    if (!existingUser) {
      return user;
    }

    // Precaution: these will exist from accounts-password if used
    if (!existingUser.services) {
      existingUser.services = {
        resume: {
          loginTokens: [],
        },
      };
    }
    if (!existingUser.services.resume) {
      existingUser.services.resume = {
        loginTokens: [],
      };
    }

    // Copy accross new service info
    existingUser.services[service] = user.services[service];
    if (user.services.resume) {
      if (user.services.resume.loginTokens) {
        existingUser.services.resume.loginTokens.push(
          user.services.resume.loginTokens[0]
        );
      }
    }

    // Create emails if needed.
    if (!existingUser.emails && user.emails) {
      existingUser.emails = user.emails;
    }

    // Create or merge the profiles if needed.
    if (!existingUser.profile && user.profile) {
      existingUser.profile = user.profile;
    } else if (user.profile) {
      existingUser.profile = Object.assign(user.profile, existingUser.profile);
    }

    // Even worse hackery
    Meteor.users.remove({ _id: existingUser._id }); // Remove the existing record
    return existingUser;              // Record is re-inserted
  }
  return user;
});
开发者ID:andyp22,项目名称:my_resume,代码行数:91,代码来源:accounts.ts

示例4: function

//         console.log("selector" + selector)
//         console.dir(selector)
//                 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;
    },
开发者ID:admirkb,项目名称:ads,代码行数:30,代码来源:users.ts

示例5:

 options.users.forEach((user:any)=>{
   let r = Meteor.users.remove({_id: user});
   console.log(r);
 });
开发者ID:p3140,项目名称:angular2-meteor-starter-kit,代码行数:4,代码来源:methods.ts

示例6:

Meteor.startup(() => {
  Posts.remove({});
  TimeLines.remove({});
  Meteor.users.remove({});
});
开发者ID:RizkiMufrizal,项目名称:Socially-Angular2-Meteor,代码行数:5,代码来源:main.ts


注:本文中的meteor/meteor.Meteor.users.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。