Table.update()

Applies to an OJAI document the updates that are contained in a DocumentMutation object.

Operations Performed

Verifies whether a document with the specified ID exists.
  • If a document with the ID does not exist, returns an error.
  • If a document with the ID does exist, applies a mutation to the document.

Example

Original document
{
	"_id" : "movie0000001",
	"title" : "OJAI -- The Documentary",
	"studio" : "MapR Technologies, Inc.",
	"release_date" : "2015-09-29",
	"trailers" : {
		"teaser" : "https://10.10.21.90/trailers/teaser",
		"theatrical" : "https://10.10.21.90/trailers/theatrical"
	},
	"characters" : [
		"Heroic Developer", 
           "Evil Release Manager", 
           "Mad Development Manager"
	],
	"box_office_gross" : 1000000000L
}
Example code for the update
public DocumentMutation buildDocumentMutation() {
    return MapRDB.newDocumentMutation()
      .increment("box_office_gross", 1000000000L);
  }
public void update(String tablePath, DocumentMutation mutation, String _id) {
    try(Table table = MapRDB.getTable(tablePath)) {
      table.update(_id, mutation);
    }
  }
Parameter Description
_id The value of the document's _id field.
tablePath The path of the table in the MapR file system. See Table Paths.
Revised document with the change in bold
{
	"_id" : "movie0000001",
	"title" : "OJAI -- The Documentary",
	"studio" : "MapR Technologies, Inc.",
	"release_date" : "2015-09-29",
	"trailers" : {
		"teaser" : "https://10.10.21.90/trailers/teaser",
		"theatrical" : "https://10.10.21.90/trailers/theatrical"
	},
	"characters" : [
		"Heroic Developer", 
           "Evil Release Manager", 
           "Mad Development Manager"
	],
	"box_office_gross" : 2000000000L
}

Permissions Required

Link to Javadoc

Table