Get docs that have changed

I have researched this for a while and can’t seem to get an answer. How would I get a list of documents that have changed on a specific bucket in Couchbase server using the C# SDK? The reason I would want this is I want to see the docs that have changed and perform a custom logging set for those specific docs only

Hi,

I may be wrong, I think you have to add a “Last modif date” in your documents.

This is what I’ve done. So It’s easy to list only modified documents. You can even do it in N1ql.

Perhaps there are better ways to do it. I will be happy to learn them.

Regards

Steeve

Thank you for the suggestion @steeve.descarpentrie I will start working with that as I keep looking for a different approach

Hi @ikiugualf,

It sounds like you are looking for some way to “trigger” C# code when a document changes? Currently, that isn’t possible (except with an approach like @steeve.descarpentrie).

Coming soon to Couchbase Server is ‘eventing’, which might be along the lines of what you want. Check out the source code in progress here: https://github.com/couchbase/eventing - however, that isn’t going to allow you to write C# code (as far as I know), but rather JavaScript code that runs server side.

Thanks @matthew.groves
So this means that while using couchbase, at any one time, I cannot get a list of documents that have changed on a bucket? Not necessarily trigger C# code but if I could ‘query’ couchbase for this info

@ikiugualf,

If you follow what @steeve.descarpentrie recommended, you can query based on a date/timestamp field. You could use a base class in C# for the objects you send to Couchbase to make this process a little easier.

1 Like