mongodb数组操作

1、查询课程中包含math,chinese的课程

db.getCollection('student').find(

{

course:{$all:['math','chinese']}

}

).pretty()

2.查询第二门课程是数学

db.getCollection('student').find(

{

course.1:math

}

).pretty()

3.查询只有两门课程

db.getCollection('student').find(

{

course.{$size:2}

}

).pretty(

posted @ 2018-05-14 23:34  江山一族  阅读(220)  评论(0编辑  收藏  举报