You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add syntactic sugar to get array instead of cursor #31
I'm using this lib with koa and it's annoying to have to yield twice to get the full array.
I would love a way to yield just once and have it return the full array. I'm unsure of what the best syntax for this would be, but something like the following would be great:
I'm willing to look into it and attempt creating a PR if you'd be interested in it. I'm also flexible on the syntax for it, I chose adding .toArray() at the end because it's very similar to what's already available.
Just for the record, we discussed a bit on IRC with @cesarandreu
I'm thinking of doing something similar to what thinky is doing by introducing an execute command.
query.run().then(function(result) {
// a value or an array
// run() automatically coerce cursors to array
})
query.execute().then(function(result) {
// execute would have the current behavior of `run`.
})
The thing is if we go for this solution, rethinkdbdash will start moving away from the official driver, and I've somehow tried to stay close to the official driver for now.
I'll think about it : )
Activity
neumino commentedon Jun 30, 2014
Just for the record, we discussed a bit on IRC with @cesarandreu
I'm thinking of doing something similar to what
thinkyis doing by introducing anexecutecommand.The thing is if we go for this solution,
rethinkdbdashwill start moving away from the official driver, and I've somehow tried to stay close to the official driver for now.I'll think about it : )
cesarandreu commentedon Jul 2, 2014
Maybe it'd make more sense to reverse them?
Have
runcontinue returning a cursor, andexecutecould return the whole result.That way it's consistent with the official driver, but it provides the added functionality.
thelinuxlich commentedon Jul 28, 2014
+1
neumino commentedon Aug 8, 2014
I plan to push that for 1.14.
Coerce cursors to array by default
thelinuxlich commentedon Aug 26, 2014
great!
neumino commentedon Aug 26, 2014
Released in 1.14
cesarandreu commentedon Aug 26, 2014
\o/