Table.insert()

Inserts a document into a table.

Operations Performed

Verifies whether a document with the specified ID already exists.
  • 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

Link to Javadoc

Table