A Node.js adapter for PawSQLite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

3 years ago
# PawSQLite Node Adapter
3 years ago
3 years ago
A Node adapter for PawSQLite using the [sqlite3 package](https://www.npmjs.com/package/sqlite3).
3 years ago
## Installation
You can install using npm:
```bash
npm install -s git+https://git.n0m.org/n0m/PawSQLite.git
3 years ago
npm install -s git+https://git.n0m.org/n0m/PawSQLite-Node-Adapter.git
3 years ago
```
## Usage
For more detailed usage, please see: [https://git.n0m.org/n0m/PawSQLite](https://git.n0m.org/n0m/PawSQLite)
```javascript
const PawSQLite = require("pawsqlite");
3 years ago
const PawSQLiteNodeAdapter = require("pawsqlite-node-adapter");
3 years ago
3 years ago
PawSQLite.registerAdapter(PawSQLiteNodeAdapter)
3 years ago
const db = await PawSQLite.open("test", {
3 years ago
adapter: 'PawSQLiteNodeAdapter'
3 years ago
});
await db.sql(`
CREATE TABLE contacts (
contact_id INTEGER PRIMARY KEY,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL
);
`);
const transaction = db.transaction();
console.log(await db.sql("SELECT * FROM contacts"));
await transaction.sql(
"INSERT INTO contacts (first_name, last_name) VALUES (?, ?)",
"John",
"Lennon"
);
await transaction.commit();
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## License
[MIT](https://choosealicense.com/licenses/mit/)