You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.1 version.
Commands: Documents: Put
Put is used to insert or update a document in a database.
Syntax
public PutResult put(String key, Etag guid, RavenJObject document, RavenJObject metadata);
Parameters | ||
---|---|---|
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 |
Example
Category category = new Category();
category.setName("My Category");
category.setDescription("My Category description");
store.getDatabaseCommands().put(
"categories/999",
null,
RavenJObject.fromObject(category),
new RavenJObject());