Open mglukhovsky opened 10 years ago
+1
I've been studying this example app for a couple hours and it hits me... all the realtime functionality is coming from socket.io. Rethinkdb could easily be swapped out for a different database. I'm not complaining because there are a couple packages here, like passport, that I want to get a handle on and it is very useful to see it all working together; however, as far as a demo for the "realtime" functionality available from Rethinkdb, the fact that chagefeeds aren't utilized indicates to me that they must not be that useful. Perhaps it is better to not have realtime coupled with data storage so that the persistence layer can be abstracted away. What is the point of using changefeeds if you have to pass it through socket.io anyway, it's like an extra step. Not trying to be contrary, just trying to understand it.
@RichardForrester: this example app was written back in 2012, before RethinkDB added changefeeds (which are the fundamental utility behind RethinkDB's realtime push functionality).
If you want to see an example where changefeeds drive realtime functionality, check out these examples:
Changefeeds differ from simply delivering the data in realtime because they allow you to open realtime streams on queries, as well as data. This is far more useful than simply storing the data in the database and performing computations / aggregations on the client-side layer -- all the hard work is done by the database. This allows you to build far more scalable applications, because the database can handle thousands (even 10k+) changefeeds on a single node (and it scales linearly from there).
Socket.io still has to be used, because you need to push your updates from the database to the browser, but when changefeeds are used, the logic is very simple (simply passing the updates directly through).
If you're interested in simplifying the stack even further, you should follow this issue, where we've been discussing building a direct browser-level integration with RethinkDB under the hood -- so you'd get a simple JavaScript API in the browser (or in Node.JS) that would let you create and drive subscriptions and realtime updates from RethinkDB at will.
Hope that makes sense!
Also, @dalanmiller and @segphault: we should revisit rebuilding these apps with changefeeds!
@mglukhovsky Thank you for the info. I think I understand your point. I'm going to check out those other examples this week and see what I see.
This example should be updated to take advantage of changefeeds (as well as use Express v4, as noted in #9).