Last active
February 19, 2021 23:59
-
-
Save arantesxyz/7fc3507e1a40210dca78d1e37d8128d9 to your computer and use it in GitHub Desktop.
Example of working with sqlite3 and async/await
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const sql = require("sqlite"); | |
| async function create(data) { | |
| if (!data) throw new Error("No data!"); | |
| return await sql.run( | |
| "INSERT INTO Veicle (id, type, model) VALUES ($id, $type, $model)", | |
| data, | |
| ); | |
| } | |
| // Calling the function | |
| create({ | |
| id: 0, | |
| type: "car", | |
| model: "uno" | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment