MongoDB - 语句Cheatsheet

CURD

insert

db.collection.insertOne()
db.collection.insertMany()

db.fruits.insertOne({name:"apple"})
db.fruits.insertMany([
{name:"apple"},
{name:"pear"}
])

find

单条件查询:db.movies.find({"year":1997})
多条件与查询:
db.movies.find({"year":1997,"type":"action"})db.movies.find({$and:[{"year":1997}, {"type":"action"}]})
多条件或查询:
db.movies.find({$or:[{"year":1997},{"type":"action"}]})
正则表达式查询:
db.movies.find({"title":/^B/})

MongoDB - 语句Cheatsheet

MongoDB - 语句Cheatsheet

搜索子文档

上一篇:大数据学习-Hadoop-HDFS


下一篇:Mac安装Brew