You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 4.2 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.

Syntax

public PutDocumentCommand(string id, string changeVector, BlittableJsonReaderObject 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 BlittableJsonReaderObject The document to store. You may use session.Advanced.EntityToBlittable.ConvertEntityToBlittable to convert your entity to a BlittableJsonReaderObject

Example

var doc = new Category
{
    Name = "My category",
    Description = "My category description"
};
var docInfo = new DocumentInfo
{
    Collection = "Categories"
};
var blittableDoc = session.Advanced.EntityToBlittable.ConvertEntityToBlittable(doc, docInfo);

var command = new PutDocumentCommand("categories/999", null, blittableDoc);
session.Advanced.RequestExecutor.Execute(command, session.Advanced.Context);