RethinkDb changefeeds 在包含 .pluck 时不起作用

RethinkDb changefeeds not working when including `.pluck`

在我使用 pluck() 投影之前,我有一个工作正常的 changefeed。如果我使用 pluck,它不会从我的关注者嵌入式集合中获取插入和删除形式的更改。

 r.table('users')
    .getAll(name, {index: 'followers'})
    //.without('password', 'phone')
    .pluck('name', 'online') // using pluck doesn't pick up changes in insert/delete from followers
    .changes({includeInitial:true});

我可以使用 without 命令,但这似乎更容易出错,因为我必须在向用户对象添加字段时随时更新该列表。

用户的在线更新 属性 在任一情况下都会在 changefeed 中获取。

为什么 pluck 不显示关注者的变化 set/collection 属性?

目前不支持此功能。检查 this ticket and this.

我不是 100% 确定,但我认为这是因为当您将 .pluck('name', 'online') 添加到末尾,然后更新 followers 数组时,changefeed 逻辑应用了 pluck然后将旧值与新值进行比较,由于两个被采摘的字段都没有改变,它决定它是一个 "trivial" 更改并删除它。 (通常忽略琐碎的更改是您想要的,因为 .pluck.changes 的主要目标之一是仅在指定字段更改时收到通知。)

不过,我认为这可能不是所期望的行为:如果它们不会导致行进入或退出订阅范围,则仅删除微不足道的更改可能更有用。我打开 https://github.com/rethinkdb/rethinkdb/issues/5205 来跟踪那个变化。