Meteor.users 维护用户 [英] Meteor.users maintaining users

查看:49
本文介绍了Meteor.users 维护用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Meteor 应用程序,我需要:

I have a Meteor app where I need to:

  1. 创建/更新应用用户,包括他们的姓名、用户名和密码.所以我想知道在以 Meteor 用户身份登录应用程序时是否可以首先这样做?换句话说,以应用程序用户身份登录时是否可以创建/更新其他应用程序用户?我试图搜索一个示例/方法,但找不到任何帮助,我们将不胜感激.

  1. Create / update app users including their name, username and password. So I was wondering if first is it possible to do so while login to the app as a Meteor user? In other words is it possible to create / update other app users while logging in as an app user? I've tried to search for an example / how to but couldn't find any so any help will be highly appreciated.

向 Meteor.users 文档添加自定义字段(例如用户类型(会计/销售...等)、电话...等)?经过研究,除了如何在更新中更新 Meteor.users 配置文件之外找不到任何示例,但在创建新用户时找不到如何执行此操作,因此我们将不胜感激.

Add custom fields to Meteor.users document (ex. User type(accountant / sales...etc), Phone...etc)? After research couldn't find any example except on how to update Meteor.users profile in update only, but couldn't find how to do so when creating the new user, so any help will be highly appreciated.

谢谢

推荐答案

要向用户添加字段,只需使用 onCreateUser 函数

To add fields to user simply use onCreateUser function

Accounts.onCreateUser(function(user) {
  user.type = "customer";
  user.phone = "123456789";
   //etc
  return user;
});

第一个问题我没看懂,但是您可以通过查询来更新用户数据,例如:Meteor.users.update({_id:this._id},{$addToSet~});

And I didn't understand first question, but you can update user data by making query, such as: Meteor.users.update({_id:this._id},{$addToSet~});

这篇关于Meteor.users 维护用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆