You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: Documents: Put

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


public PutDocumentCommand(String id, String changeVector, ObjectNode document)
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


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

DocumentInfo docInfo = new DocumentInfo();

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