Node: Knex postgres query doesn't trigger unless 'then' is appended

292 Views Asked by At

I'm using Node with postgresql. I'm trying to do a knex query to the bd.

Why this query doesn't work without the then() call?

knex('test').insert(User1).then();
2

There are 2 best solutions below

0
Tuan Anh Tran On

I think it's expected behavior.

0
Sombriks On

it's because the framework expects you to either fulfill the promise or to invoke any other provided output interfaces

to chain the promise output is one of the cleaner ways to end the query building step, see this little example, hope it helps.