Affichage des articles dont le libellé est mongodb. Afficher tous les articles
Affichage des articles dont le libellé est mongodb. Afficher tous les articles

jeudi 6 août 2015

[Ansible] problem when executing a mongo script on a remote server

When you want to execute the command mongo on the remote server (for exemple when you want to do mongo --host myserver --port 27017 myscript.js you must do that in your playbook :

-shell: mongo --host myserver --port 27017 < myscript.js 

Source : http://stackoverflow.com/questions/4837673/how-to-execute-mongo-commands-through-shell-scripts#comment21193090_4837678

dimanche 9 septembre 2012

Versioning with MongoDB

For storing history of changes to a record, we can use this kind of structure :

address:


{
    _id : "id of address book record",
    "city" : "San Francisco", 
    "state" : "California"
}




history_address:

{
    _id : "id of history address book record",
    changes : { 
                1234567 : { "city" : "Omaha", "state" : "Nebraska" },
                1234568 : { "city" : "Kansas City", "state" : "Missouri" }
               }
}



1234567 and 1234568 are timestamps.

And this is the query for storing history :
db.history_address.update({_id: ID}, {$set : { changes.12345 : CHANGES } }, true);


More details here :
http://stackoverflow.com/questions/4185105/ways-to-implement-data-versioning-in-mongodb

Categories