Skip to content

Instantly share code, notes, and snippets.

@hrdmtr
Last active December 19, 2015 16:19
Show Gist options
  • Save hrdmtr/5983227 to your computer and use it in GitHub Desktop.
Save hrdmtr/5983227 to your computer and use it in GitHub Desktop.
MogoDB memo

ミリ秒まで指定する

db.{collection}.find({"lastUpdated": { "$gt" : ISODate("2013-07-12T18:41:50.362+09:00"), "$lt" : ISODate("2013-07-12T18:41:50.367+09:00") }})

削除条件を間違えないように削除する

var q = {"lastUpdated": { "$gt" : ISODate("2013-07-12T18:41:50.360+09:00"), "$lt" : ISODate("2013-07-12T18:41:50.367+09:00")}};
db.ssnwRenewalCode.find(q).count()
db.ssnwRenewalCode.find(q)
db.ssnwRenewalCode.remove(q)
db.ssnwRenewalCode.find(q).count()

インデックス付与

db.{collection}.ensureIndex({"station_id" : 1});

csvをimportする

mongoimport --db {dbname} --collection {collection name} --type csv --file "{file path}" --fields field1,field2,field3…```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment