How can I store userid's of meteor account-users in a collection2 array. 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. It isn't recommended to put _id
in the schema. 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. That should solve your issues.