Consistent Views

I’m sure there is a very simple answer to this but I cannot find it.

The scenario is that a value is stored in a doc and a view is called immediately (few seconds later, sometimes even minutes).
The view needs to return the new value but it fails to include it in the view results.

What should I do for the query to return the new value: add a delay, poll the view until the value returns or add some flag to the store call ?

Thanks.

What you want is akin to “Read Your Own Writes”, ie. strong consistency of the view query.
To do so, simply use the relevant option on the ViewQuery:

myViewQuery.Stale(StaleState.False); :smile: :+1:

It will force a wait for the indexation to finish before the view returns a result (so of course it is a performance vs consistency tradeoff).

2 Likes