【问题标题】:Unsupported projection option: $concat On Azure CosmosDb不支持的投影选项:Azure CosmosDb 上的 $concat
【发布时间】:2018-10-10 19:28:15
【问题描述】:

我在本地主机上编码了 Mongoose 查询,它工作正常,但在 Azure CosmosDb 上部署时我遇到了错误

"message":"{status: 500,message:'不支持的投影选项:$concat'

    User.aggregate()
        .project({
            fullname: { $concat: ['$first_name', ' ', '$last_name'] },
            first_name: 1,
            last_name: 1,
            email: 1,
            contact: 1,
            image: 1,
            role: 1,
            isactive: 1
        })
        .match(condition).sort("fullname").skip(startIndex).limit(limit).exec((err, users)=>{
            if (err) return next(err)
            if(users == null)
                return res.status(422).send({header:"User Error", content: "Unable to fetch Users"});
            count = User.countDocuments({isactive: true},(err, count)=>{
                if (err) return next(err)
                if(count == null)
                return res.status(422).send({header:"User Error", content: "User not found"});
                // usersObject = users.map(o => o.toObject());
                usersObject = users;
                usersObject.forEach((user, index) => {
                    usersObject[index].image = '/public/image/user_images/' + user.image;
                });
                return res.send({
                    success:true,
                    msg: {
                        users: usersObject,
                        count
                    }
                });
            });
        });

User 是正在使用的 users 表的模型。在架构中定义

【问题讨论】:

    标签: node.js azure mongoose deployment azure-cosmosdb


    【解决方案1】:

    Azure cosmos Db中有一个选项---> YourDb --->(在设置部分下)预览功能---->启用前2个选项 1. MongoDB 聚合管道启用 2. MongoDB 3.4有线协议(版本5)启用

    【讨论】:

      猜你喜欢
      • 2020-12-01
      • 1970-01-01
      • 2021-09-21
      • 2019-09-02
      • 1970-01-01
      • 2016-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多