一、常用命令:
<
mongod
mongo
show dbs
use seata_db
进入seata_db
show collections
<
db.user.insert({"name":"宋文龙","age":17,"hobby":["play","study"]})
db.user.find()
mongoinport
<
db.user.find()
db.user.find({"name":"swl"})
db.user.find({"name":"swl","age":17})
db.user.find($or: [{"name":"swl","age":17}])
db.user.find({"age":{$lt: 20}})
db.user.find({"age":{$gt: 15}})
db.user.find({"age":{$gt: 15,$lt: 20}})
db.user.find().limit(4)
db.user.find().limit(4).skip(4)
<
db.user.update({"name":"swl"},{$set: {"name":"songwl"})
db.user.update({"name":"swl"},{"name":"songwl"})
<
db.user.remove({"name":"swl"})
db.user.remove({"name":"swl"},{justOne: true})
db.user.remove({})
db.user.drop()
db.dropDatabase()
<
db.user.find({"age":{$lt: 11,$gt: 5}).sort("age": 1)
db.user.find({"age":{$lt: 11,$gt: 5}).sort("age": -1)
|