henningc
henningc

Reputation: 215

Updating documents in RavenDB

If you add, delete or rename a property on a persisted entity, what's the easiest way to update the documents in RavenDB?

Upvotes: 17

Views: 11393

Answers (2)

Matt Warren
Matt Warren

Reputation: 10291

RavenDB supports PATCH commands, see the docs for more info for more info. This way you can update a document directly without having to pull it from the server, update it and then send it back.

Also you can run patches over multiple documents by using Set-based queries, see here for some more info. This lets you do the equivalent of

UPDATE Users
SET IsActive = false
WHERE LastLogin < '2010-05-10'

Upvotes: 16

user156888
user156888

Reputation:

raven also has object tracking. so the following works:

var doc = _session.Load<MyDocType>(docId);
doc.PropertyToChange = "New Value";
_session.SaveChanges();

Upvotes: 21

Related Questions