Closed dcsan closed 8 years ago
Can you be a bit more specific? If I understand async/await correctly, it works seamlessly with promises, right? And since most, if not all, of the Document
methods return relevant data/objects, I'd think something like this should work with async/await:
var smiths = await Person.loadMany({lastName: 'Smith'});
smiths.forEach(function(s) {
console.log(s.firstName, s.lastName);
});
Admittedly I haven't done any testing with async/await on Camo yet. Since a big part of Camo is emphasizing the new JavaScript syntax/features, I'll have to start testing it more.
Thanks for bringing this up!
I guess you're right, it would be just using the existing camo API in an ES7 environment.
might be nice to see a little demo node app with the required Babel transpilers etc all bundled up, and maybe a nice pipeline with webpack.
I guess node still doesn't support it natively yet. according to this maybe not for awhile: http://kangax.github.io/compat-table/es7/#babel
and I guess there are gotchas around inner/outer functions and where you actually 'await' http://pouchdb.com/2015/03/05/taming-the-async-beast-with-es7.html
I did see some demos with Fibers and mongo drivers, and having used Meteor a lot, their mongo API is really easy to work with even on node 10.x series (they wrap everything in fibers)
looks interesting https://www.npmjs.com/package/nodent
Thanks for the info. I'm working on creating some more formal documentation for Camo, so maybe I'll add a section of examples, including ones using async/await.
If you have any other suggestions or questions, please let me know. Otherwise I'm going to close this issue.
Thanks!
I like the camo API a lot, but wonder if you'd consider adding a way to use it more in a 'synchronous' style with the new await / async ES7 stuff?