zoukankan      html  css  js  c++  java
  • mongo views

    db.itemsView.drop();

    db.items.aggregate([
    {
    "$match": {
    "status": "true"
    }
    },
    {
    "$unwind": {
    "path": "$globalOptions",
    "preserveNullAndEmptyArrays": true
    }
    },
    {
    "$lookup": {
    "from": "globaloptiongroups",
    "localField": "globalOptions",
    "foreignField": "_id",
    "as": "globaloptiongroups"
    }
    },
    {
    "$unwind": {
    "path": "$globaloptiongroups",
    "preserveNullAndEmptyArrays": true
    }
    },
    {
    "$group": {
    "_id": "$_id",
    "globaloptiongroups": {
    "$push": "$globaloptiongroups"
    },
    "name": {
    "$first": "$name"
    },
    "merchantId": {
    "$first": "$merchantId"
    },
    "customerOptions": {
    "$first": "$customerOptions"
    },
    "properties": {
    "$first": "$properties"
    },
    "price": {
    "$first": "$price"
    },
    "picture": {
    "$first": "$picture"
    },
    "description": {
    "$first": "$description"
    },
    "category": {
    "$first": "$category"
    },
    "order": {
    "$first": "$order"
    }
    }
    },
    {
    "$project": {
    "_id": 1,
    "name": 1,
    "merchantId": 1,
    "options": 1,
    "price": 1,
    "picture": 1,
    "description": 1,
    "category": 1,
    "order": 1,
    "groupOptions": {
    "$setUnion": [
    "$groupOptions",
    "$customerOptions"
    ]
    }
    }
    },
    {
    "$sort": {
    "order": 1
    }
    }
    ]).saveAsView("itemsView");

  • 相关阅读:
    41、XAML text editing
    使用JavaScript和DOM动态创建和修改表格(转)
    ThinkPHP入门
    PHP字符串
    sicily 6773. 用指针交换两个矩阵
    sicily 6572. partial sum
    sicily 1934. 移动小球
    sicily 1323. Switch text
    sicily 6766. tmp
    sicily 1293. 3n+1数链问题
  • 原文地址:https://www.cnblogs.com/jayruan/p/7154212.html
Copyright © 2011-2022 走看看