2015-12-22
2015-12-10
Meteor - MongoDB collection inspection from browsers console
COLLECTION_NAME.find({}).collection._docs._map;
2015-12-03
MongoDB - Unique compound index creation
db.COLL_NAME.createIndex(
{
FIELD_NAME : 1
, FIELD_NAME_2: 1
}
, { unique: true }
);
2015-12-02
MongoDB - Execute a custom script file and export the results to a flat file using the command line
mongo localhost:3001/DATABASE_NAME SCRIPT_FILE_NAME.js >> TARGET_FILE_NAME.EXTENSION
MongoDB - Export query to flat file from the command-line
mongo SERVER_NAME_OR_IP:PORT_NUMBER/DATABASE_NAME --eval "var c =
db.COLLECTION_NAME.find(); while(c.hasNext()) {printjson(c.next())}"
>> TARGET_FILE_NAME.TARGET_FILE_NAME_EXTENSION
Actual example:
mongo localhost:3001/meteor --eval "var c = db.mycoll.find(); while(c.hasNext()) {printjson(c.next())}" >> test.txt
Another example/thread at:
http://stackoverflow.com/questions/12823990/how-to-get-mongo-command-results-in-to-a-flat-file
Actual example:
mongo localhost:3001/meteor --eval "var c = db.mycoll.find(); while(c.hasNext()) {printjson(c.next())}" >> test.txt
Another example/thread at:
http://stackoverflow.com/questions/12823990/how-to-get-mongo-command-results-in-to-a-flat-file
MongoDB - Meteor command-line import
mongoimport --jsonArray -h localhost:3001 -d meteor -c COLLECTION_NAME --file "/PATH_TO_FILE/FILE.EXTENSION"
PS. Specify the address (-h) of your Meteor's MongoDB instance.
PS. Specify the address (-h) of your Meteor's MongoDB instance.
2015-12-01
MongoDB - How to insert integer numbers
db.COLLECTION_NAME.insert({ FIELD_NAME : NumberInt(NUMERIC_VALUE) });
Subscribe to:
Posts (Atom)