简体   繁体   English

meteorjs中collection2中的用户数组

[英]User array in collection2 in meteorjs

How can I store userid's of meteor account-users in a collection2 array. 我如何在collection2数组中存储流星帐户用户的用户ID。 My definition of schema looks like. 我对架构的定义如下所示。 Will this work? 这样行吗?

I wanted an approach to add associated users to a collection. 我想要一种将关联用户添加到集合中的方法。 Whereby I wanted to control who are allowed to see this particular document of the collection. 因此,我想控制允许哪些人查看此收藏集中的特定文档。 Is there a better way to do this than how I'm modelling. 有没有比我建模更好的方法了。

 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] } 

Each document receives an _id automatically. 每个文档都会自动收到一个_id It isn't recommended to put _id in the schema. 不建议将_id放在模式中。 Not sure it will even work for you. 不确定它是否还能为您工作。

If you want to know if it will work, I recommend trying it yourself! 如果您想知道它是否可以工作,建议您自己尝试! You have the schema already. 您已经有了模式。

For user permissions, I recommend using the alanning:roles package. 对于用户权限,我建议使用alanning:roles包。 That should solve your issues. 那应该解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM