I am trying to run a simple query in my local Postgres db to return the User with an ID of 1 and save that value in the variable record
. I'm using Sails.js and am in the Sails Console when I'm running these commands. I can get the query to print the object by running
var record = User.find(1).exec(console.log);
,
but I can't seem to figure out how to save that value in a variable.
I've tried quite a few other things. await
doesn't work in the Sails Console and all their documentation seems to use that.
I've also tried:
var record = User.find(1).exec(function(err, u){
return u[0];
});
var record = User.find(1).exec(function(err, u){
return u;
});
If I run:
var record = User.find(1).exec(function(err, u){
console.log(Object.keys(u[0]));
});
it does print out all the keys to the user I'm querying, so I'm able to access the object, just can't figure out a way to save that object in a variable inside the Sails Console.
Any ideas?