首页 > 解决方案 > 数据未使用 mongodb 填充到 nodejs 的选项标签中

问题描述

        Restaurant.aggregate([
            {
                "$geoNear": {
                    "near": customerLocation,
                    "distanceField": "distance",
                    key: "restaurantLocation",
                    "spherical": true,
                    "maxDistance": radius,
                    query: obj

                }
            },
            { $match:{userType:data.userType}},
            { $lookup: {
               from: 'Tag',
               let:{    tags  :  "$tags"  },
               pipeline:[
                   {  $match : {  $expr :  {$in  :  [  "$_id"  ,  "$$tags"]}}}
               ],
               as:'tags'
            }},
         
            { $sort: sort },
            { $limit: pageOptions.limit },
            { $skip: pageOptions.page * pageOptions.limit }
            
            
        ])

我正在使用简单的查询根据由 0 或 1 组成的用户类型来查找附近的餐馆。0 表示餐馆,1 表示杂货店。我想用标签表查找。该字段包含对象 ID 的标记数组。我也只想填充标签结果。但没有找出为什么我的查询没有运行

标签: node.jsmongodbaggregation-frameworkmongodb-lookup

解决方案


推荐阅读