zoukankan      html  css  js  c++  java
  • Mongodb的基本语法

    1.基本语法,简要语句。

    #显示所有数据库
    show dbs
    #操作此数据库
    use [db]
    #创建集合(表)
    db.createCollectin("[table]")
    #在集合中插入一条json数据(此方法可以不用上一步直接创建集合)
    db.[table].insert({...})
    #显示所有集合(表)
    show collections
    #删除当前操作的数据库
    db.dropDatabase()
    #删除集合
    db.[table].drop()
    #查看一个集合的数据
    db.[table].find()
    #格式化
    db.[table].find().pretty()
    #查询第一条
    db.[table].findOne()
    #更新
    db.[table].update({查询条件},{$set:{更新值}})
    #查询
    db.[table].find({查询条件})
    #查询年龄大于二十
    #gt(>),lt(<),eq(=),gte(>=)
    db.[table].find({userage:{$gt:20}})
    #删除
    db.[table].remove({删除条件})

    2.这篇博客写的不错

    https://www.cnblogs.com/leskang/p/6000852.html

  • 相关阅读:
    605. Can Place Flowers
    1184. Distance Between Bus Stops
    1711. Count Good Meals
    1710. Maximum Units on a Truck
    566. Reshape the Matrix
    980. Unique Paths III
    212. Word Search II
    每日总结
    每日总结
    每日总结
  • 原文地址:https://www.cnblogs.com/chao-zjj/p/9945100.html
Copyright © 2011-2022 走看看