zoukankan      html  css  js  c++  java
  • MongoDB小结27

    我们有这样的数据

    {
         "_id" : 1,
         title: "abcdef",
         isbn: "6969696969",
         author: { last: "codingwhy<span style="font-family: Arial, Helvetica, sans-serif;">", first: "com" },</span>
         copies: 5
      }

    现在使用project来变换输出

    db.books.aggregate( 
         [
              { $project : { title : 1 , author : 1 } } 
         ]
     )

    可以得

     { 
        "_id" : 1,
        "title" : "abcdef", 
        "author" : { "last" : "codingwhy", "first" : "com" } 
     }
    
    在$project里,我们指明(筛选)了要显示的数据,title和author,_id是自带的,可以用 _id:0 来将其过滤掉

  • 相关阅读:
    Java 高级文件处理
    drf10
    drf9
    drf8
    drf7
    drf6
    drf5
    drf4
    drf3
    drf2
  • 原文地址:https://www.cnblogs.com/caohaifeng/p/5550734.html
Copyright © 2011-2022 走看看