Created
October 3, 2018 19:17
-
-
Save shawn-kb/2ba6ac549ac1653405b3322acc25a12b to your computer and use it in GitHub Desktop.
problem with async / await in objection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function tryByMonitor(sensorObject, monitor){ | |
const sensorQuery = sensorObject.query() | |
.select('*') | |
.where('monitor', monitor) | |
.limit(1) | |
.then(function (queryResult){ | |
if (! queryResult.length ) return null | |
console.log(queryResult[0].monitor + " from function"); | |
return queryResult[0]; | |
}) | |
} | |
async function getSensor(){ | |
const sensor = await tryByMonitor(GpsSensor, "32002bgps"); | |
console.log(sensor.monitor) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment