RethinkDB 替换查询在 python 中不起作用

RethinkDB replace query is not working in python

我正在尝试使用替换键替换现有文档 word.but 它不起作用。有人能告诉我除此之外还有什么我应该做的吗?

  r.db("Siyara2D").table("Vessels").get(1).replace({
            "x": "2222",
            "y": "1111",

  }).run(db_connection)

如果您遇到错误:

Inserted object must have primary key `id`

解决方案是将主键保留在文档中。例如:

r.db("Siyara2D").table("Vessels").get(1).replace({
    "id": 1,
    "x": "2222",
    "y": "1111",
}).run(db_connection)