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

Fix docs for JS run, and add collect to docs #25

Closed
ptrln opened this issue Nov 11, 2012 · 5 comments
Closed

Fix docs for JS run, and add collect to docs #25

ptrln opened this issue Nov 11, 2012 · 5 comments
Assignees
Milestone

Comments

@ptrln
Copy link

ptrln commented Nov 11, 2012

When running in node

r.table('example').run(function(thing){
    console.log(thing);
});

Only one "thing" will be returned, even though there are multiple in the table. When running in the console using runp(), an array of all the records are returned, which is correct. But when using run(), only one record is returned.

@coffeemug
Copy link
Contributor

@ptrln -- this is by design, it's a way to use 'cursors' in node. If the callback returns true, it gets called again with the next record. If it returns nothing/false, it doesn't get called again (rethink assumes you don't want the rest of the records). An alternative is to call 'collect' instead of run, which will give you the whole dataset.

@wmrowan -- could you please improve the docs on this, and add 'collect' to the js docs?

@ghost ghost assigned wmrowan Nov 11, 2012
@ptrln
Copy link
Author

ptrln commented Nov 11, 2012

@coffeemug , Thanks! I thought it might be something like that. Do you mean something like r.table('example').collect()? I tried running collect, and I got this error - TypeError: Object [object Function] has no method 'collect'

@coffeemug
Copy link
Contributor

Hmm, perhaps collect isn't exposed -- @wmrowan could you chime in?

Regardless, you'd need to pass collect a callback, which gets called with an array of documents.

@coffeemug
Copy link
Contributor

ahh, checked the code, I believe it's query.run().collect(callback)

@coffeemug
Copy link
Contributor

Renaming the issue -- this is a documentation problem.

@wmrowan wmrowan closed this as completed Nov 15, 2012
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

3 participants