You are currently browsing legacy 3.0 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 PutResult put(String key, Etag guid, RavenJObject document, RavenJObject metadata);
key String unique key under which document will be stored
etag Etag current document etag, used for concurrency checks (null to skip check)
document RavenJObject document data
metadata RavenJObject document metadata

public class PutResult
  private String key;
  private Etag etag;

  public String getKey() {
    return key;

  public void setKey(String key) {
    this.key = key;

  public Etag getEtag() {
    return etag;

  public void setEtag(Etag etag) {
    this.etag = etag;
Return Value
Key String unique key under which document was stored
Etag Etag stored document etag


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

  new RavenJObject());