Table.replace()
Replaces a document in a table with the specified document.
Operations Performed
- If a document with the ID does not exist, returns an error.
- If a document with the ID does exist, replaces the document.
Example
- Original document
-
{ "_id" : "000001"; "a" : 1 }
- Example code
-
Document document = MapRDB.newDocument() .setId("000001") .set("b", 2); public void replace(String tablePath, Document document) { try(Table table = MapRDB.getTable(tablePath)) { table.replace(document); } catch (DocumentNotFoundException e) { System.out.printf("Document with _id %s does not exist in table %s\n", document.getId(), tablePath); } }
- Replacement document
-
{ "_id" : "000001"; "b" : 2 }
Permissions Required
- The
writeAce
permission on the volumes where the JSON tables that contain the documents are located. For information about how to set permissions on volumes, see Setting/Modifying Whole Volume ACEs. writeperm
on the column families in the row. See How to Obtainreadperm
orwriteperm
on a Field.