数据库
首页 > 数据库> > MongoDB - 语句Cheatsheet

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/})

查询条件条件对照表

查询逻辑条件对照表

搜索子文档

标签:语句,name,color,MongoDB,db,movies,Cheatsheet,fruits,find
来源: https://www.cnblogs.com/rachel-aoao/p/mongodb_curd.html