rethinkdb 中的 changes() 如何工作?

How does changes() work in rethinkdb?

rethinkdb.com 主页中的示例未按预期运行。

r.db("test").tableCreate("game");
r.db("test").table("game").indexCreate("score");
r.db("test").table("game").insert({name: "brandon", score: 60});
r.db("test").table("game").insert({name: "leon", score: 80});
r.db("test").table("game").insert({name: "connor", score: 100});
r.db("test").table("game").orderBy({index: "score"}).limit(3).changes()

输出:

{ "new_val": { "id": "c727b9eb-5aaa-46f9-bc09-a6c879cfbfa0" , "name": "brandon" , "score": 60 } } { "new_val": { "id": "b59d4314-b78c-48c9-8780-0f9d3a6b6887" , "name": "leon" , "score": 80 } } { "new_val": { "id": "519343b1-cd98-4969-8f07-7bff5d981c81" , "name": "connor" , "score": 100 } }

r.db("test").table("game").insert({name: "mike", score: 70});

没有任何变化,但由于按分数排序必须进行更改。

r.db("test").table("game").get("519343b1-cd98-4969-8f07-7bff5d981c81").update({score: 50}) // {name: "connor"}

仍然没有.. 那么为什么有序列表没有按应有的方式更新?

这似乎是 Web 界面的故障。 运行 这些来自客户端驱动程序的命令(我在 2.1.3 和 2.1.4 上使用 JavaScript 驱动程序尝试过)显示了预期的变化,只是数据资源管理器没有正确更新。如果将选项卡切换到 Table 视图并返回,您可以看到光标已收到底部的更改。

不幸的是,这是数据浏览器中的错误。它已在 https://github.com/rethinkdb/rethinkdb/issues/4852 中修复,并且很快将作为小版本推出修复。在发布之前,我建议改用其中一种驱动程序来测试这些查询。