1.数据库操作:
use database; db.dropDatabase(); show dbs;
mongodump 备份 mongorestore恢复 mongostat监控mongotop
2.集合操作
db.createCollection() db.collection.insert()
db.collection.drop() db.collection.renameCollection()
show collections db.getCollection('class')
3.文档插入
insertOne() insertMany() insert() save()
4.查找函数
find(query,field)
5.数据操作
db.collection.findOne(query,field)
- query操作符的使用
(1) eq:17}},{_id:0})
(2) lt:'Tom'}},{_id:0})
(3) gt:17,lte ne nin
7.逻辑操作符 (与:遇假则假,或:遇真则真,非:真变假,假变真)
(1) and[{age:{or nor
8.数组操作符
(1) 查找数组中包含的元素
(2)size 根据数组中元素的个数
#(4)$slice 用于feild参数,表示查找数组中的哪些项
(5)db.class0.distinct('age') db.class0.find().pretty()
db.class0.find().limit(n){前n条数据}
db.class0.find().skip(n){跳过前n条数据}
db.class0.find().count(){统计数据数目}
db.class0.find().sort({field:1/-1}){数据排序}
## 函数可以连续调用
## 可以利用序列号获取
网友评论