【发布时间】:2018-12-17 22:28:15
【问题描述】:
Meteor 集合插入正在插入子文档而不是普通文档。请参阅下面的插入语句:
return Profile.insert({
_id: this.userId,
"firstName": firstname,
"lastName": lastname,
"state": state,
"mobile": mobile,
"alias": alias,
"email": email,
"bvn": bvn,
"createdAt": new Date(),
"updatedAt": new Date(),
});
这是 MongoDB 控制台中的结果:
meteor:PRIMARY> db.profile.find().pretty()
{
"_id" : "uNECMJJkCtQXhSs33",
**"firstName" : {
"firstName" : "firstName",
"lastName" : "lastName",
"state" : "state",
"mobile" : 55325235522535,
"alias" : "alias",
"email" : "email",
"bvn" : 6364634664
},**
"createdAt" : ISODate("2018-12-15T03:23:33.243Z"),
"updatedAt" : ISODate("2018-12-15T03:23:33.243Z")
}
以下是我的期望
meteor:PRIMARY> db.profile.find().pretty()
{
"_id" : "uNECMJJkCtQXhSs33",
"firstName" : "firstName",
"lastName" : "lastName",
"state" : "state",
"mobile" : 55325235522535,
"alias" : "alias",
"email" : "email",
"bvn" : 6364634664
"createdAt" : ISODate("2018-12-15T03:23:33.243Z"),
"updatedAt" : ISODate("2018-12-15T03:23:33.243Z")
}
【问题讨论】:
-
你有什么问题?
-
根据你的代码,这个结果是不可能的。
createdAt和updatedAt是正确的。你确定你给我们的代码是正确的吗?或者,您是在运行可能导致这种情况的 dbhooks,还是某种模式? -
您插入的文档与来自 Meteor.users 的用户文档具有相同的 _id,我认为这甚至是不可能的。但只是假设它有效,它是否解决了您为 userId 使用另一个属性而不是 _id 的问题?
-
@Mikkel,我没有任何 DBhooks。
-
@Jankapunkt,我做了修改,但结果还是一样。