mongodb - Does Moongoose 3.8.8 support $position operator? -


does moongoose 3.8.8 (the lastest version) support $position (http://docs.mongodb.org/manual/reference/operator/update/position/) operator mongodb 2.6.0?

in following code example new elements inserted in end of array useractivity.activities:

model:

var useractivity = new schema({     userid: {type:string, required:true, unique:true},     activities: [activity] });  var activity = new schema({     act: {type: number, required:true}, }); 

query:

var activity = { act: 1 };  model.useractivity.update( { _id: dbact._id }, { $push: { activities: {                 $each: [ activity ],                 $position: 0             }          } }, function (err, numaffected) {     if (!err) {     //     } }); 

this doesn't matter , never matters "framework" implementation , not mind explaining why.

every single "framework" ( such mongoose, mongoid, doctrine, mongoengine, etc, etc, etc ) built upon basic "driver" implementation has in cases been developedby mongodb staff themselves. basic functionality ther if need "delve" down level in order use "native" methods.


so here native usage example in case:

list.collection.update( {}, { "$push": {     "list": {       "$each": [ 1, 2, 3 ],       "$position": 0 }     } },function(err,numaffected) {   console.log("done");  }); 

note "collection" method used model, getting "raw" collection details driver. using it's method , not "wrapped" method may doing additional processing.


the next , basic reason if cannot find method , application of operators need here simple fact.

every single operation used methods in every framework , basic driver method call "runcommand" method in basic api. since basic call available everywhere ( in form or another, because has ), can find advertised on mongodb site every language implementation on any framework.

but short call particular request is, since not method call part of bson arguments passed in, of course there no restriction particular language driver use this.

so can use these new argument without of course updating recent version. nice methods if do.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -