【问题标题】:AWS-DocumentDB not supported $lookup operator, any Alternative of $lookup in AWS-DocumentDBAWS-DocumentDB 不支持 $lookup 运算符,AWS-DocumentDB 中 $lookup 的任何替代项
【发布时间】:2019-09-30 08:54:55
【问题描述】:

DocumentDB 不支持“$lookup”运算符,DocumentDB 中 $lookup(MongoDB) 的任何其他替代方案。

这里是 DocumentDB 支持的运算符列表。 https://docs.aws.amazon.com/documentdb/latest/developerguide/mongo-apis-aggregation-pipeline.html

将一个Nodejs应用从MongoDB迁移到DocumentDB,数据迁移成功但是在运行应用时出现这个错误。

{ MongoError: Aggregation stage not supported: '$lookup'
at Connection.<anonymous> (/.../node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:443:61)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at processMessage (/.../node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:364:10)
at TLSSocket.<anonymous> (/.../node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:533:15)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
at TLSWrap.onread (net.js:607:20)
ok: 0,
errmsg: 'Aggregation stage not supported: \'$lookup\'',
code: 304,
name: 'MongoError',
[Symbol(mongoErrorContextSymbol)]: {} }

【问题讨论】:

    标签: node.js amazon-web-services mongoose aws-documentdb aws-documentdb-mongoapi


    【解决方案1】:

    [10/16 更新] Amazon DocumentDB 如何支持 $lookup:https://aws.amazon.com/about-aws/whats-new/2019/10/amazon-documentdb-add-additional-aggregation-pipeline-capabilities/

    您可以在此处找到支持的 API/阶段/运算符的最新列表:https://docs.aws.amazon.com/documentdb/latest/developerguide/mongo-apis.html

    另外,请查看以下内容以了解最近的发布:https://aws.amazon.com/documentdb/resources/

    【讨论】:

    • 有没有 $lookup 的替代品? DocumentDB 支持。
    • @BhanwarChaudhary,通常,连接是规范化数据的结果(类似于关系模型),并且 $lookup 运算符使您能够连接两个集合。替代方法包括对数据模型进行非规范化,或者根据大小/性能限制,在应用层中执行连接。我知道您更喜欢 $lookup,我们非常感谢您的反馈。
    • 谢谢,但是应用程序构建和运行我必须将它迁移到 DocumentDB,我无法更改代码或查询,所以我将使用 MongoDB Atlas 而不是 DocumentDB。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    • 2019-06-20
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多