2015-11-04 29 views
0

如何将userrid的流星帐户用户存储在collection2数组中。我对模式的定义看起来像。这会工作吗?meteorjs中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] 
 
    }

回答

0

每个文档自动接收一个_id。不建议在模式中放置_id。不知道它甚至会为你工作。

如果你想知道它是否会工作,我建议你自己尝试!你已经有模式。

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

+0

手动获取用户标识,然后将集合更新为字符串数组,而不是关联用户标识的 – Jayanth

+0

我不知道您在说什么。这是一个问题还是一个陈述? –

+0

这是一个声明,关于我如何解决问题,感谢您的帮助。 – Jayanth