Replacing the document key?


#1

Hi all,

I’m wondering if it is possible to change the document key of a document I have in scope.
So I read in a document, store it in a dictionary, change the key and then write it back.
When I try and change the key I’m told it is a read only attribute.

What I am trying to achieve is this… I want to read in a document, make a slight change to it but the write it back as a new document (with a new key).

Any advice appreciated.

Thanks,

Joe


#2

Can you post some code of what you’re trying to do?

The Result objects are read only… you can simply do:

value = cb.get('oldkey').value
value['field'] = 'newvalue'
cb.upsert('newkey', value)