我正在尝试使用 meteor-collection2 来验证我的收藏。
我在服务器端有一项服务:
Meteor.methods
UserSignUpService: (options) ->
# create user
Accounts.createUser options
我在客户端调用:
Meteor.call 'UserSignUpService',
email: 'my.email@domain.com'
password: 'mypassword'
profile:
name: 'me'
这是我的架构:
# user profile
UserProfile = new SimpleSchema
name:
type: String
min: 1
max: 50
optional: false
# user
User = new SimpleSchema
emails:
type: [Object]
optional: false
"emails.$.address":
type: String
regEx: SimpleSchema.RegEx.Email
"emails.$.verified"
type: Boolean
createdAt:
type: Date
profile:
type: UserProfile
optional: false
services:
type: Object
optional: true
blackbox: true
# links to user collection
Meteor.users.attachSchema User
但是,当创建用户时,我的 mongo 集合中并非所有字段:
{ "_id" : "ikvBq95JBLXMCSnhT", "emails" : [ { "address" : "my.email@domain.com" } ] }
而它应该是:
{ "_id" : "WNkjGFhNkLpRR2Jex", "createdAt" : ISODate("2015-08-06T09:00:59.887Z"), "services" : { "password" : { "bcrypt" : "$2a$10$QvMLuI.Pv0bzzii3ZZP...fHfUlU9KiYfcsC2VHBf6q1OSPM6cfTW" }, "resume" : { "loginTokens" : [ { "when" : ISODate("2015-08-06T09:01:00.002Z"), "hashedToken" : "9KyqjRVSWm0nfIlS0sqODRmddlJ5GaG3mJ4+RMItOhk=" } ] } }, "emails" : [ { "address" : "my.email@domain.com", "verified" : false } ], "profile" : { "name" : "me" } }
对这个问题有任何想法吗?
非常感谢 !