zoukankan      html  css  js  c++  java
  • MongoDB增删改查

    1.SQL与MongoDB概念映射

    SQL Terms/ConceptsMongoDB Terms/Concepts
    database database
    table collection
    row document or BSON document
    column field
    index index
    table joins embedded documents and linking

    primary key

    Specify any unique column or column combination as primary key.

    primary key

    In MongoDB, the primary key is automatically set to the _idfield.

    aggregation (e.g. group by)

    aggregation pipeline

    See the SQL to Aggregation Mapping Chart.

    2.建表

      先创建一张mongo表,右击已创建的数据库test,点击addcollection..

    图片

      输入Collection Name,点击ok;

    3.插入数据

      在创建的表中新增列与数据,右击表选择Insert document

    图片

      点击Insert,刷新表。

    4.查询数据

      右击表格,点击Find

    图片

    4.1 查询日期的方式需要在{Find}框中写

      {

        "endDate":ISODate("2013-12-30T16:00:00Z")

      }
      这样才能正确匹配到日期

    4.2 查询普通数据:{"age":1,"name":"aaa"}

    4.3 查询大于,小于

    图片

    4.4 {Find}中写where语句

      $lt:小于,$lte:小于等于,$gt:大于,$gte:大于等于,$in:在...之中,$or:或者

      ${Where}:右击表格,点击Find2,比Find多了一个where;写表达式

    图片

      where可以写函数:

    图片

    4.5 排序${Sort}

      给某个字段排序升序排序{"name":1},降序{"name":-1};注:小于0表示降序,大于等于0表示升序

    图片

    4.6 查询字段${Fields}

    图片

      字段的值是1表示:查出id与该字段;值为0表示:查出表中所有字段,不包括该字段

    4.7 其他选项

    图片

      skip:表示跳过多少条数据,例如表中有三条,skip为2,那么只有查出一条数据

      limit:表示分页

      detail:勾上表示界面上显示${Fields}与${Sort}

    5.修改数据

      $in:同时修改多条数据,mongo中日期修改需要先格式化ISODate

      mongovue执行完修改语句后,它的控制台会自动生成语句

    6.删除数据

      点击Remove

      执行remove后,会弹出删除的数据条数:

    7.MongoDB官方手册

    https://docs.mongodb.org/manual/

  • 相关阅读:
    HTML5的自定义属性的使用总结
    yaf
    tp5
    简单易懂的命名空间及use的使用
    惮道安装方法
    centOS 7 gitlab安装
    PHP html mysql js 乱码问题,UTF-8(乱码)
    免费CDN公共库——网站提速 静态资源库
    如何写好接口(php写app移动端接口示例)
    Fiddler
  • 原文地址:https://www.cnblogs.com/blueoverflow/p/4896580.html
Copyright © 2011-2022 走看看