mongodb数组操作

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

db.getCollection('student').find(

{

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

}

).pretty()

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

db.getCollection('student').find(

{

course.1:math

}

扫描二维码关注公众号,回复: 853994 查看本文章

).pretty()

3.查询只有两门课程

db.getCollection('student').find(

{

course.{$size:2}

}

).pretty(

猜你喜欢

转载自www.cnblogs.com/qiyc/p/9038753.html