我正在从 Legacy Realm 及其 Realm.Sync 侦听器迁移到 Change Streams,我试图弄清楚如何轻松获取更新时返回的完整对象。
case "update": {
const { documentKey, fullDocument } = change;
console.log(`updated document: ${documentKey}`, fullDocument);
break;
}
有没有办法获取包含关系数据的完整文档?
例如fullDocument
:
{
"_id": "b03dcd5d-94dc-7254-6aff-44d5818390ca",
"_partition": "test"
"Message": "Test",
"Sender": "51f717ad-afbc-c3d6-779a-72db53f8b708",
"SeenBy": [
"51f717ad-afbc-c3d6-779a-72db53f8b708"
],
}
而不是Sender
id,我想获取发件人文档,在SeenBy
.
{
"_id": "b03dcd5d-94dc-7254-6aff-44d5818390ca",
"_partition": "test"
"Message": "Test",
"Sender": {"_id": "51f717ad-afbc-c3d6-779a-72db53f8b708", "Name":"John"},
"SeenBy": [
{"_id": "51f717ad-afbc-c3d6-779a-72db53f8b708", "Name":"John"}
],
}