I wonder what I am doing wrong.
I use Sailsv0.10 and mongo2.6.0 and want to update an array field (using $push) in a collection via native.
My model:
module.exports = {
schema: true,
attributes: {
username: {
type: 'string',
required: true
},
pubs: {
type: 'array',
defaultsTo: []
},
...
My function:
User.native(function (err, collection) {
collection.update({username:aUsernameVariable},{$push:{pubs:aPubsVariable}}, function (err) {
});
It works so far. But why does that not work as a query with the id field?
User.native(function (err, collection) {
collection.update({id:anIdVariable},{$push:{pubs:aPubsVariable}}, function (err) {
});
I definately use the right id for the query to test it.
What am I doing wrong? Or is that a ObjectId type conversion Problem of the Sails-Mongo Adapter
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…