Table.increment()
Increments the value of a numeric field by the amount of the specified value.
Operations Performed
- Verifies that a field at the specified path exists in the document with the specified ID. If the field at the specified path does not exist, this operation creates it with the specified value.
- Verifies that the field is of the same numeric data type as the passed value.
- Adds the passed value to the existing value.
Example
public void incrementField(String tablePath, String _id, String fieldPath, short inc) {
try(Table table = MapRDB.getTable(tablePath)) {
table.increment(_id, fieldPath, inc);
}
}
Parameter | Description |
---|---|
_id |
The value of the document's _id field. |
fieldPath |
The path of the field in dotted notation. See Dotted Notation for Identifying Fields. |
inc |
The short value. |
tablePath |
The path of the table in the MapR file system. See Table Paths. |
Permissions Required
- The
readAce
andwriteAce
permissions 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. readperm
andwriteperm
on the specified field, if this field exists. See How to Obtainreadperm
andwriteperm
on a Field.writeperm
on the parent field, if the specified field does not exist. See How to Obtainreadperm
orwriteperm
on a Field.