Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Await is not Working with Sqlite3 in Node Js and Express JS #1

Closed
one-numan opened this issue May 5, 2024 · 3 comments
Closed

Await is not Working with Sqlite3 in Node Js and Express JS #1

one-numan opened this issue May 5, 2024 · 3 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@one-numan
Copy link
Owner

one-numan commented May 5, 2024

Goal : I am trying Build accessing DB with raw Query and Goal is to MVC & Not used ORM

Issue : Write an Raw Quer to getting Data from SQLite3 Database But Issue I get but response is {} empty and After Some time get data in console.log

Get Request , End Point : api/v1/emp/all

image

db_getAll() is Function Using In Model Section , That get Data from DB

Its give Data but await is not working here...
image

Console Output

image

@one-numan one-numan added the good first issue Good for newcomers label May 5, 2024
@one-numan one-numan self-assigned this May 5, 2024
@one-numan
Copy link
Owner Author

one-numan commented May 5, 2024

After Multiple Search I get something from Stack overflow
Article URL : https://stackoverflow.com/questions/62456867/cannot-await-for-sqlite3-database-get-function-completion-in-node-js

Line From StackOverFlow users and Its Correct working..

Since you want to use async/await, and the node-sqlite3 (sqlite3) library does not support the Promise API, you need to use the node-sqlite (sqlite) library, which is a wrapper over sqlite3 and adds support for the Promise API.
I install SQLite and get

I after Followed this Its Working.

@one-numan
Copy link
Owner Author

one-numan commented May 5, 2024

After have Query and Still not satisfied this answer ⬆️ .

So Let's go to official NPM document of SQLite & Github's Code Snippet URL
NPM URL : https://www.npmjs.com/package/sqlite
Library Github URL : https://github.com/kriasoft/node-sqlite

image

@one-numan
Copy link
Owner Author

My Issue is Resolve and Your's

URL : f767bf1

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant