【发布时间】:2022-01-06 14:29:02
【问题描述】:
我有以下文件
{"_id": "1", "posts": [{"text": "all day long I dream about", "datetime": "123"}, {"text": "all day long ", "datetime": "321"}]}
{"_id": "1", "posts": [{"text": "all day long I dream about", "datetime": "123"}, {"text": "all day long ", "datetime": "8888"}, {"text": "I became very hungry after watching this movie...", "datetime": "8885"}]}
我希望将 text 字段连接到一个新字段,将 datetime 字段连接到一个新字段,同时还将数组元素连接到一个字符串中,新字段如下
{"_id": "1", "text": "all day long I dream about, all day long ", "datetime": "123, 321"}
{"_id": "1", "text": "all day long I dream about, all day long ,I became very hungry after watching this movie... ", "datetime": "123, 8888, 8885"}
直接在 Mongodb 服务器上执行此操作的最佳方法是什么?有没有这样的方法?
【问题讨论】:
标签: mongodb concatenation