我想知道我做错了什么。
我使用 Sailsv0.10 和 mongo2.6.0 并希望通过本机更新集合中的数组字段(使用 $push)。
我的模型:
module.exports = {
schema: true,
attributes: {
username: {
type: 'string',
required: true
},
pubs: {
type: 'array',
defaultsTo: []
},
...
我的功能:
User.native(function (err, collection) {
collection.update({username:aUsernameVariable},{$push:{pubs:aPubsVariable}}, function (err) {
});
到目前为止它有效。但是为什么这不能作为带有 id 字段的查询呢?
User.native(function (err, collection) {
collection.update({id:anIdVariable},{$push:{pubs:aPubsVariable}}, function (err) {
});
我肯定会为查询使用正确的 id 来测试它。
我究竟做错了什么?还是说是 Sails-Mongo Adapter 的 ObjectId 类型转换问题