meteorjs中collection2中的用户数组

时间:2015-11-04 14:30:23

标签: javascript meteor meteor-collection2

如何将userid的meteor帐户用户存储在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]
  }

1 个答案:

答案 0 :(得分:0)

每个文档自动收到_id。建议不要在模式中放置_id。不确定它是否适合你。

如果您想知道它是否有效,我建议您自己尝试一下!你已经有了架构。

对于用户权限,我建议使用alanning:roles包。这应该可以解决你的问题。