0

The CouchDB docs make it pretty clear that single-document updates are ACID. But I'm wondering whether that applies to updates to views that are triggered as a result of a document update.

Suppose I have a view function in place to display the count of documents with a specific value on the 'type' field. What happens if the server crashes immediately after I insert a document with that type but before the view has had time to update? Does CouchDB guarantee that the view will be updated the next time the server starts? Or do I have to wait until some other event triggers recomputation of the view?

Community
  • 1
  • 1
nradk
  • 680
  • 9
  • 19

1 Answers1

1

Views, like the _changes feed, are actually just built using the same append-only model as the databases themselves. When you update a document, you aren't actually waiting for the views to be updated as well. In fact, views are only updated when they are queried.

As a result, even if the database crashes between a document change and a view rebuild, that won't matter as the database is effectively a journal/stream of changes and a view be built from it at any time.

Dominic Barnes
  • 28,083
  • 8
  • 65
  • 90