【发布时间】:2015-08-06 11:00:20
【问题描述】:
我正在尝试使用 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" } }
对这个问题有什么想法吗?
非常感谢!
【问题讨论】:
-
您是如何在集合中查找用户的?通过控制台还是通过 mongo 客户端?
-
通过控制台:db.users.find()
-
而
db.users.find()只给出_id和emails字段? -
是的,因为我的用户对象中只有这两个字段...
标签: node.js mongodb meteor meteor-collection2