0
我想爲我的Web應用程序擁有不同類型的用戶。他們將擁有普通用戶的所有方法,但具有不同的架構,特別是針對settings
和profile
。例如:將Meteor.users劃分爲不同的模式
var UserBase = {
emails: {
type: [Object],
optional: true
},
// ... etc not important
}
AdminSchema = new SimpleSchema(_.extend(UserBase, {
profile: {
type: AdminProfileSchema
},
settings: {
type: AdminSettingsSchema
}
}));
UserSchema = new SimpleSchema(_.extend(UserBase, { // yada yada });
// more or less what I want to do:
Meteor.users.attachSchema(AdminSchema, { role: "admin" });
Meteor.users.attachSchema(UserSchema, { role: "user"});
是否有可能將不同的架構附加到Meteor.users,假設沒有衝突?
我也將指向流星-roles軟件包,如果你不知道它:https://github.com/alanning/meteor-roles有很好的內置角色功能,適用於鐵路由器和其他人。 – Jon
我剛剛通過添加一些驗證來完成它,檢查數據類型不能設置,除非他們有問題的角色,這很好,所以接受 – corvid