MongoDB相关的笔记
连接
mongo ホスト名/DB名
数据库列表 (Databases list)
show dbs;
收藏清单
show collections;
有条件获取
- where AAA = BBB
db.access_log.find({code: 200});
- where AAA = BBB and CCC = DDD
db.access_log.find({code: 200, method: "GET"});
- where AAA in (BBB, CCC, …)
db.access_log.find({code: {$in: [200, 300, 400]}});
一种感觉- Yī
最近获得的最新十项成果。
db.コレクション名.find().sort({_id: -1}).limit(10);
如果是像访问日志这样的东西,通过时间筛选会更快。
把今天的日期放入ISODate。
db.コレクション名.find({
time: {$gte: ISODate("2012-06-28T00:00:00+09:00")}
}).sort({_id: -1}).limit(10);