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

Implement ordered ranges #175

Open
neumino opened this issue Feb 3, 2015 · 4 comments
Open

Implement ordered ranges #175

neumino opened this issue Feb 3, 2015 · 4 comments
Labels

Comments

@neumino
Copy link
Owner

neumino commented Feb 3, 2015

For

Users.orderBy({index: "score"}).limit(10).changes()

We should return an array of 10 documents and maintain it up to date.
This is pending some changes on the server: rethinkdb/rethinkdb#3714

If the changes don't make it for 2.0, I'll implement a work around (a bit less efficient than if the feeds return the positions of the changes).

@neumino
Copy link
Owner Author

neumino commented Mar 31, 2015

That's technically possible now.

The question is how to expose it. Here's what I have in mind

io.on('connection', function(socket){
    Users.orderBy({index: "score"}).limit(10).changes({includeStates: true}).run().then(function(range) {
        socket.broadcast.emit(JSON.stringify(range.toArray()));
        range.each(function(patch) { // equivalent to range.on("change", function(patch) {
            socket.broadcast(patch)
        })
    })
});

A few things to note:

The main idea is that you can get the sequence at any time with toArray on your Node.js app, and you can easily send it to your user (without sending the whole array).

Thoughts anyone?

@marshall007
Copy link
Contributor

I would prefer it if range was just an array by default and .toPatch() implemented the JSON patch behavior you described. I think the more common case is that people will just emit the entire array to the client each time.

@neumino neumino added the feature label Aug 9, 2015
@singggum3b
Copy link

any chance this feature gonna make it?

@neumino
Copy link
Owner Author

neumino commented Sep 16, 2016

Hum the API hasn't been quite nailed down so there's more work needed here.

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

No branches or pull requests

3 participants