mercredi 16 décembre 2020

How does Knex await execute a database query?

I'm trying to understand how the await keyword is being used in KNEX. Take the following example:

knex.schema.createTable( ... );

this will return this which is an instance of SchemaBuilder. It will not execute the create table query in the database. However if I stick and await in front of it.

await knex.schema.createTable( ... );

This will now execute the create query in the database.

My understanding is that await is used to wait for a promise resolution but in this case it feels like something else is going on because not awaiting the function doesn't return a promise.

How does this work?

Aucun commentaire:

Enregistrer un commentaire