简体   繁体   中英

Knex.js with native promises

My question is rather simple: How can one use Native promises instead of the Bluebird-like promises bundled with knex.js? I scanned the docs for such an option but I found nothing

Use the built in Promise library:

 let myPromiseFunc = (bool) => { return new Promise((resolve, reject) => { if (bool) resolve("Its true") else reject("Its false") }) } myPromiseFunc(false) .then((resp) => { console.log(resp) }).catch((err) => { console.log(err) }) 

Using native ES6 promises in knext.js is not supported yet. There's a discussion(open issue) about your request. But for now you have to go with bluebird.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM