美文网首页
mongo shell

mongo shell

作者: EricLee_1900 | 来源:发表于2020-03-27 12:22 被阅读0次

    常用

    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()  //固定格式,删除当前库(不用跟参数,区分大小写)

    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" : "数学", "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':'数学'}}, {'$group':{_id:"$period",count:{'$sum':1}}}])

    { "_id" : "初中", "count" : 158 }

    { "_id" : "高中", "count" : 162 }

    相关文章

      网友评论

          本文标题:mongo shell

          本文链接:https://www.haomeiwen.com/subject/mkaoehtx.html