mongoDB基础语法

    xiaoxiao2021-03-25  91

    1.基础查询

    db.getCollection('goods_record_2015-09').find({uid:'uid'})

    2.多条件查询

    db.getCollection('goods_record_2015-09').find({uid:'uid',resID:'res_16035'})

    3.查询指定的列

    db.getCollection('goods_record_2015-09').find({uid:'uid',resID:'res_16035'},{uid:1}) 其中1表示要显示的字段,0表示要排除的字段

    4.排序

    db.getCollection('goods_record_2015-09').find({uid:'uid'}).sort({num:1}) 其中1表示升序,-1表示降序

    5.模糊查询

    db.getCollection('goods_record_2015-09').find({uid:/^123/})  ----以123开头 db.getCollection('goods_record_2015-09').find({uid:/123/})     ----包含123
    转载请注明原文地址: https://ju.6miu.com/read-22943.html

    最新回复(0)