Table.insert()
Inserts a document into a table.
Operations Performed
- If a document with the ID already exists, returns an error.
- If a document with the ID does not exist, inserts the document.
Example
public Document buildDocument() {
return MapRDB.newDocument()
.set("title", "OJAI -- The Documentary")
.set("studio", "MapR Technologies, Inc.")
.set("release_date", Values.parseDate("2015-09-29"))
.set("trailers.teaser", "https://10.10.21.90/trailers/teaser")
.set("trailers.theatrical", "https://10.10.21.90/trailers/theatrical")
.setArray("characters", ImmutableList.of("Heroic Developer", "Evil Release Manager", "Mad Development Manager"))
.set("box_office_gross", 1000000000L);
}
public void insertDocument(String tablePath, String _id, Document document) {
try(Table table = MapRDB.getTable(tablePath)) {
table.insert(_id, document);
}
}
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. |
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.