zoukankan      html  css  js  c++  java
  • mongodb的联合查询

    db.assets.aggregate([
    {$match:{"stationId":"HNRDC"}},
    {$match:{"categoryType":"TYPE_FOLDER_COMMON"}},
    {$match:{"extraData.folder_used":{$gte:0}}},{
    $lookup: {
      from: "departs", 
      localField: "parentId", 
      foreignField: "_id", 
      as: "group"
    }
    },
    {
    $unwind: {
      path: "$group",
      preserveNullAndEmptyArrays: false 
    }
    },
    
    {
          $project: {
           name:1,
           stationId:1,
           categoryType:1,
           "extraData.folder_used":1
           }
    },
    
    ]);
    db.groups.aggregate([
    {$match:{"stationId":"HNRDC"}},
    {
    $lookup: {
      from: "mobjects", 
      localField: "_id", 
      foreignField: "parentId", 
      as: "mos"
    }
    },
    
    {
          $project: {
          name:1,
          stationId:1,
          mos: {
          $filter: {
                input: "$mos",
                   as: "item",
                   cond: { $eq: [ "$$item.categoryType", "TYPE_FOLDER_COMMON" ] }
                }
             }
          }
    },
    {
    $unwind: {
      path: "$mos",
      preserveNullAndEmptyArrays: false 
    }
    },
    
    ]);
  • 相关阅读:
    nginx 相关命令
    uni-app跨域解决
    vue-cli3.0的项目搭建
    vue.js
    Flex布局
    javascript 数组排重
    IE的hack问题浅谈
    div自身高度、屏幕高度
    bootstrap轮播和百叶窗
    面向对象
  • 原文地址:https://www.cnblogs.com/liangblog/p/14582251.html
Copyright © 2011-2022 走看看