meteorjs 中 collection2 中的用户数组
User array in collection2 in meteorjs
如何将 meteor 帐户用户的用户 ID 存储在 collection2 数组中。我对模式的定义看起来像。这行得通吗?
我想要一种将关联用户添加到集合的方法。因此,我想控制允许谁查看该集合的这个特定文档。有没有比我建模更好的方法。
name: {
type: String,
max: 100,
optional: false
},
billingAddress: {
type: AddressSchema
},
shippingAddress: {
type: [AddressSchema]
},
type: {
type: String,
max: 20,
allowedValues: ['Vendor', 'Customer', 'Self', 'Employee'],
optional: false
},
phones: {
type: [String]
},
emails: {
type: [String],
regEx: SimpleSchema.RegEx.Email
},
website: {
type: String,
regEx: SimpleSchema.RegEx.url
},
isCustomer: {
type: Boolean,
optional: false
},
isVendor: {
type: Boolean,
optional: false
},
isSearchable: {
type: Boolean,
optional: false
},
associatedUsers: {
type: [Meteor.users]
}
每个文档都会自动收到一个 _id
。不建议将 _id
放入架构中。不确定它是否适合您。
如果你想知道它是否有效,我建议你自己尝试一下!您已经有了架构。
对于用户权限,我推荐使用alanning:roles
包。那应该可以解决您的问题。
如何将 meteor 帐户用户的用户 ID 存储在 collection2 数组中。我对模式的定义看起来像。这行得通吗?
我想要一种将关联用户添加到集合的方法。因此,我想控制允许谁查看该集合的这个特定文档。有没有比我建模更好的方法。
name: {
type: String,
max: 100,
optional: false
},
billingAddress: {
type: AddressSchema
},
shippingAddress: {
type: [AddressSchema]
},
type: {
type: String,
max: 20,
allowedValues: ['Vendor', 'Customer', 'Self', 'Employee'],
optional: false
},
phones: {
type: [String]
},
emails: {
type: [String],
regEx: SimpleSchema.RegEx.Email
},
website: {
type: String,
regEx: SimpleSchema.RegEx.url
},
isCustomer: {
type: Boolean,
optional: false
},
isVendor: {
type: Boolean,
optional: false
},
isSearchable: {
type: Boolean,
optional: false
},
associatedUsers: {
type: [Meteor.users]
}
每个文档都会自动收到一个 _id
。不建议将 _id
放入架构中。不确定它是否适合您。
如果你想知道它是否有效,我建议你自己尝试一下!您已经有了架构。
对于用户权限,我推荐使用alanning:roles
包。那应该可以解决您的问题。