//常用操作:
// 1.查看数据库
show dbs
// 2.创建并使用数据库
use tst
// 3.查看当前工作的数据库
db
// 4.创建集合并插入一条数据
db.goods.insert({"name":"辣条", "price":0.5})
// 5.查看所有表
show tables
// 6.查询表中所有数据
db.goods.find()
// 7.删除表操作
db.goods.drop()
// 8.删除数据库
db.dropDatabase()
# 增加数据操作:
db.tablename.insert({dict})
# 示例: 增加数据操作:
db.goods.insert({"name":"鸭梨", "price":0.5})
db.goods.insert({"name":"鸭梨", "price":1})
db.goods.insert({"name":"干脆面", "price":0.5})
db.goods.insertOne({"name":"单身狗粮", "price":4.5})
db.goods.insertMany([{"name":"小洋人", "price":3.5}, {"name":"麦香鸡块","price":5.5}])
# 查询数据操作:
db.tablename.find({dict})
# 示例:查询操作
  # 1.简单查询操作:
  db.goods.find().limit(4).sort({"price":1})     // sort("定位的键":+-1):用于
对查询结果进行排序, 1升序, -1降序
  # 2.条件查询:db.tablename.find({"定位的键":"值"})
  db.goods.find({"name":"鸭梨"})  // 等值查询
  # 3.and 与 or
  db.goods.find({"name":"鸭梨", "price":0.5})  // and查询:根据多个条件共同定位数据
  db.goods.find({$or:[{"name":"鸭梨"},{"price":3.5}]})
  # 4.非等值查询:db.goods.find({"定位的键":{$...:"值"})
  db.goods.find({"price":{$gt:0.5}})   // 大于: $gt 
  db.goods.find({"price":{$gte:4.5}})   // 大于等于: $gte
  db.goods.find({"price":{$lt:4.5}})   // 小于: $lt
  db.goods.find({"price":{$lte:4.5}})   // 小于等于: $lte
  db.goods.find({"price":{$ne:5.5}})   // 不等于: $ne
  db.goods.find({"price":{$lt:5.5, $gt:0.5}})  //上下限范围查询
  db.goods.find({$or:[{"price":{$lt:3.5}}, {"price":{$gt:4.5}}]}) // 非上下限范
围查询
# 更新数据操作:
db.table.update({定位字典}, {指定修改的键值})
# 示例:更新数据操作:
db.goods.update({"price":0.5},{$set:{"price":5}}) 
    # 参数中的第一个字典用于定位要修改的数据
    # 参数中的第二个字典是指定要更新已定位的数据
    # 第二个参数中的字典是指定要将哪个字段的修改为什么
# 删除数据操作:
db.tablename.remove({定位字典})
# 示例:删除数据操作:
db.goods.remove({"price":5})