Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differenciate insert and update events #10

Open
matcho opened this issue Aug 20, 2018 · 2 comments
Open

Differenciate insert and update events #10

matcho opened this issue Aug 20, 2018 · 2 comments

Comments

@matcho
Copy link

matcho commented Aug 20, 2018

Hello,

We're currently using arangochair (@voondo 's fork in fact, because of authentication issues) and are rather happy with it !
Nevertheless, it would be great to be able to subscribe to insert and update events separately.

This page says that "Separate events for insert and update are currently not possible but will be part of a future update."

Any roadmap for this please ?

Thanks

@yerboogieman
Copy link

yerboogieman commented Apr 26, 2019

I have been going through the arangochair code to see how it works and I think I see how it's possible to do this. If you look at the code inside index.js, you will see that it is polling the database change log every second or so by making a call to the logger-follow REST API endpoint. If you call this API within a REST client like Postman, or some such, you will see that inserts generally have a transaction ID (tid) of "0" and updates generally have a tid > 0. I can see how I could probably make this change seamlessly and I'm considering creating a pull request to add this functionality, but I'm posting the comment here first just in case the author has any advice to tell me that things are not as I have stated them herein.

@yerboogieman
Copy link

yerboogieman commented Apr 28, 2019

Okay, I have now completed the aforementioned enhancement and created a pull request.

So now, instead of:

// explicit
no4.subscribe({collection:'users', events:['insert/update', 'delete']});

You can listen for 'insert' and 'update' changes separately, as in:

// explicit
no4.subscribe({collection:'users', events:['insert', 'update', 'delete']});

or just:

// subscribe to all events in the users collection
no4.subscribe('users');

I also fixed some field parsing bugs I found. If you want to use the enhancement before the pull request gets merged, just go grab it from my forked arangochair project:

https://github.com/yerboogieman/arangochair

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants