Rethinkdb removing data from documents

梦想的初衷 提交于 2019-12-06 06:52:36

Below is a query that removes a key from the root of the document:

r.table('foo').get(document_id).replace(r.row.without('key'))

You can also do it for multiple documents as follows:

r.table('foo').filter(condition).replace(r.row.without('key'))

As of the upcoming 1.8 release, you will also be able to do it for nested keys as follows:

r.table('foo').get(document_id).replace(r.row.without({data: { key1: true}}))

Currently, the commands above essentially replace the document with the copy of itself without the relevant keys on the server. In the next few releases this will be heavily optimized to minimize document copying in memory (so while it looks like you're replacing the document with a copy of itself without a key, under the hood the operation will be performed destructively without any copying). Future releases might update the underlying structure so that the full document won't have to be written to disk.

If you use the without command, you won't have to do anything to take advantage of these optimizations (other than upgrading the server).

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!