Waterline version: 0.13.3
Node version: 8.11.1
NPM version: 5.8.0
Operating system: Ubuntu 17.10
Hello!
When I trying to use Waterline in standalone mode, I could not find the correct method to perform native queries. With Sails.JS the sendNativeQuery method is used which I could not find in the instances of the models. Does anyone know how I can perform these queries?
Thank you!
`Waterline.start(waterlineConfig, function(err, orm) {
if (err) {
return console.error(err);
}
Waterline.getModel('User', orm).sendNativeQuery(sql);
console.log(orm);
});`
Hi @Dragons0458! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:
As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks!
*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]
Ok, fixed!
@Dragons0458 Thanks for posting, we'll take a look as soon as possible.
For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.
+1
+1
Still not exist?
Having the same problem one solution I found to get around immediately was, a rather ugly solution.:
await new Promise(async (acp, rjt) => {
await Banks._adapter.mongodb(config.database.host, async (err, db) => {
if (err) {
rjt();
}
let data = await db.collection("accounts").aggregate(where);
acp(await data.toArray());
});
});
Ok, fixed!
Can you please post solution?
@macpatel, they were replying to sailsbot, as in they fixed their github issue format. Unfortunately no response from sails folks yet.
@tswayne @macpatel @tharyckgusmao @ImTheDeveloper @Dragons0458 - Hey everyone, we're currently moving all the Waterline issues to Sails (balderdashy/sails) for greater exposure and status monitoring. We appreciate all the efforts on this proposal so far. I apologize this one hasn't had a response from us yet and will be sure to bring it up to the team and get back to everyone. Thanks.
@tswayne @macpatel @tharyckgusmao @ImTheDeveloper @Dragons0458
Alright, I brought this up with the team and came to the conclusion that this can eventually change to become easier in a future release when we pull sails-hook-orm鈥檚 datastore methods into the Waterline core.
Currently, to send a native query using Waterline standalone, you鈥檙e responsible for getting and maintaining your own connection, using sendNativeQuery() provided on the .driver and releasing the connection when you鈥檙e finished.
The solution for the foreseeable future is to use the .driver method. If it's feasible, you can also try out Sails' built-in Waterline at the moment.
@johnabrams7 Very cool is the initiative and the return to the class.
As I moved away from the project that worked, I can not give you feedback.
But anyway thank you very much.
Having the same problem one solution I found to get around immediately was, a rather ugly solution.:
await new Promise(async (acp, rjt) => { await Banks._adapter.mongodb(config.database.host, async (err, db) => { if (err) { rjt(); } let data = await db.collection("accounts").aggregate(where); acp(await data.toArray()); }); });
thanks it works for me
Most helpful comment
+1