nosql - Rethinkdb removing data from documents -


i'm trying remove portions of data documents given simple structure, deeper , heavier project goes:

{     id: "...",     name: "...",     phone: "...",     data: {         key1: "val1",         ...     }     ... } 

i'm aware there no way of updating/removing sections nested parts other replacing whole tree updated tree.

for example, if want delete key1 document data, need update documents data section copy of key1 not contained

document.update({data: new dict without key1}) 

is there eaiser way of deleting portion root of document -like name field- without updating whole document copy of not contain name key , value? have deep copy , filter document every time need remove portions of data?

below query removes key root of document:

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

you can multiple documents follows:

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

as of upcoming 1.8 release, able nested keys follows:

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

currently, commands above replace document copy of without relevant keys on server. in next few releases heavily optimized minimize document copying in memory (so while looks you're replacing document copy of without key, under hood operation performed destructively without copying). future releases might update underlying structure full document won't have written disk.

if use without command, won't have take advantage of these optimizations (other upgrading server).

hope helps.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -