Commands: Documents: Put

Put is used to insert or update a document in a database.

Syntax

public PutDocumentCommand(String id, String changeVector, ObjectNode document)
Parameters
id String unique ID under which document will be stored
changeVector String Entity changeVector, used for concurrency checks (null to skip check)
document ObjectNode The document to store. You may use session.advanced().getEntityToJson().convertEntityToJson to convert your entity to a ObjectNode

Example

Category doc = new Category();
doc.setName("My category");
doc.setDescription("My category description");

DocumentInfo docInfo = new DocumentInfo();
docInfo.setCollection("Categories");

ObjectNode jsonDoc = session.advanced().getEntityToJson().convertEntityToJson(doc, docInfo);
PutDocumentCommand command = new PutDocumentCommand("categories/999", null, jsonDoc);
session.advanced().getRequestExecutor().execute(command);