常用
yuanpei_offline
mongo?mongodb://yuanpei_developer:yuanpei_developer_345384@10.10.254.13:27017/kb_y
db.exampaper.update({'status': 'searched', 'valid': true}, {$set:{'status':'ctb_recommend'}})
db.question.find({'recognization.reco_sim_questions': {$exists: 1}, subject: '語文'}, {'recognization.reco_sim_questions': 1, 'recognization.text': 1})
db.question.find({'subject':'生物', 'status':'marked', 'recognization.ctime': {'$gt':ISODate("2019-03-27T21:50:16Z")}}, {'recognization.reco_questions': 0, 'recognization.text':0, 'recognization.knowledges':0, 'text':0, 'mark':0}).pretty()
db.exampaper.find({is_ctb_paper:true, 'subject':'化學'}, {'subject':1, is_ctb_paper:1, period:1})
1)刪除表
db.表名.drop() 固定格式,要在當前庫下的表名
> db.t1.drop()
true
2)刪除庫
db.dropDatabase() ?//固定格式,刪除當前庫(不用跟參數(shù),區(qū)分大小寫)
3)刪除表記錄
db. 集合名 .remove({ 條件 }) ?//刪除與條件匹配的所有記錄
db. 集合名 .drop(); ? ? ? ? ?//刪除表
mongoexport -u kboe_developer -p kboe_developer_439765 -h 10.10.254.13 --port 27017 -d kboe -c student --limit 50000 -o test_5w.json
mongoimport -u test -p test -h 10.10.254.13 --port 27017 -d test -c test_lxj_5w --file test_5w.json
$group 用法
> db.lxj_teacher_feature_0.aggregate([{'$match':{'free_timetable':{'$exists':true}}},{'$group':{_id:"$skilled_subject", count:{'$sum':1}}}])
{ "_id" : 8, "count" : 9 }
{ "_id" : 9, "count" : 12 }
{ "_id" : 7, "count" : 8 }
{ "_id" : 3, "count" : 181 }
{ "_id" : 6, "count" : 31 }
{ "_id" : 2, "count" : 329 }
{ "_id" : 5, "count" : 69 }
{ "_id" : 4, "count" : 98 }
{ "_id" : 1, "count" : 141 }
db.planner_level.aggregate([{'$match':{'disabled':0}},{'$group':{_id:"$level", count:{'$sum':1}}}])
> db.lxj_create_exampaper_all_0113.aggregate([{'$match':{'subject':{'$exists':true}}}, {'$group':{_id:"$subject",count:{'$sum':1}}}])
{ "_id" : "語文", "count" : 132 }
{ "_id" : "英語", "count" : 178 }
{ "_id" : "物理", "count" : 169 }
{ "_id" : "數(shù)學", "count" : 320 }
{ "_id" : "政治", "count" : 71 }
{ "_id" : "地理", "count" : 87 }
{ "_id" : "生物", "count" : 104 }
{ "_id" : "歷史", "count" : 87 }
{ "_id" : "化學", "count" : 118 }
> db.lxj_create_exampaper_all_0113.aggregate([{'$match':{'subject':'數(shù)學'}}, {'$group':{_id:"$period",count:{'$sum':1}}}])
{ "_id" : "初中", "count" : 158 }
{ "_id" : "高中", "count" : 162 }