Does Moongoose 3.8.8 support $position operator?

17 views
Skip to first unread message

Roman

unread,
Apr 15, 2014, 5:55:54 AM4/15/14
to mongoo...@googlegroups.com

Does Moongoose 3.8.8 (the lastest version) support $position (http://docs.mongodb.org/manual/reference/operator/update/position/) operator from MongoDB 2.6.0?

In the following code the new elements is inserted in the end of the array userActivity.activitie

var userActivity = new schema({ userId: {type:String, required:true, unique:true}, activities: [activity] }); var activity = new schema({ act: {type: Number, required:true}, });

var activity = { act: 1 };

model
.userActivity.update(
{ _id: dbact._id },
{ $push: { activities: {
            $each
: [ activity ],
            $position
: 0
         
}
 
}
},
function (err, numAffected) {
 
if (!err) {
 
// do something
 
}
});




It seems that $push together with $position doesn't work (I use the latest MongoDb 2.6 and the latest Mongoose 3.8.8) - the $position operator is ignored and new element is inserted in the end of array!
What am I doing wrong?


Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages