Constructor promisification
See original GitHub issueGiven this constructor: https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
new sqlite3.Database(filename, [mode], [callback])
where “callback” function will be called when the database was opened successfully or when an error occurred, how can it be promisified? Because this does not works:
(new sqlite3.Database(':memory:', sqlite3.OPEN_READWRITE|sqlite3.OPEN_CREATE)).then(function () {...});
Thanks in advance.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Promisify imported class (constructor) with bluebird in ES6 + ...
The important part is that the classes' constructor needs to accept a callback as it does database connections and file I/O. If I...
Read more >How to promisify constructor's handling methods? #558 - GitHub
I'm creating a wrapper to return the "apis" object back to the wrapper's clients. I cannot find a way to use the promises...
Read more >JavaScript Promisification - W3docs
Promisification is a long term for a straightforward transformation. It represents a conversion of the function, which accepts a callback into a function ......
Read more >Promise() constructor - JavaScript - MDN Web Docs
The Promise() constructor is primarily used to wrap functions that do not already support promises.
Read more >Promisification - Bluebird JS
Most libraries can be promisified by requiring the library's classes (constructor functions) and calling promisifyAll on the .prototype .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@benjamingr promisify doesn’t work with constructors
Making constructors perform io operations is a horrible idea o_0
That said - you can convert it to a promise API just like anything else.
In the future - please keep the issue tracker for bugs and feature requests and ask support questions in Stack Overflow - as explained in the contribution guidelines.