对不起我的英语不好。我使用包 useraccounts:bootstrap 进行登录、注册等。注册后如何向 Meteor.users 集合添加任意数据。例如,我希望用户在注册后有一个值为 'false' 的字段 'status' 或带有注册时间的字段 'time'。谢谢你。
最佳答案
如果用户需要提供数据,您需要customize the UI并添加所需的字段。
在服务器上,您可以附加一个 onCreateUser()
创建新用户时设置数据的回调。
import _ from 'lodash';
Accounts.onCreateUser((options, user) => {
// add your extra fields here; don't forget to validate the options, if needed
_.extend(user, {
status: false,
createdAt: new Date()
});
return user;
});
options
参数包含来自客户端的数据。
关于meteor - 如何将自定义字段添加到 Meteor.users 集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37070438/