Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/farjs/better-sqlite3-wrapper
Thin api wrapper around better-sqlite3 and bun:sqlite to allow cross- runtime/engine usage
https://github.com/farjs/better-sqlite3-wrapper
api-wrapper better-sqlite3 bun cross-engine cross-runtime db sql sqlite sqlite-database sqlite3 sqlite3-database
Last synced: about 7 hours ago
JSON representation
Thin api wrapper around better-sqlite3 and bun:sqlite to allow cross- runtime/engine usage
- Host: GitHub
- URL: https://github.com/farjs/better-sqlite3-wrapper
- Owner: farjs
- License: mit
- Created: 2023-03-28T16:26:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-13T17:25:43.000Z (over 1 year ago)
- Last Synced: 2024-10-28T11:55:21.628Z (11 days ago)
- Topics: api-wrapper, better-sqlite3, bun, cross-engine, cross-runtime, db, sql, sqlite, sqlite-database, sqlite3, sqlite3-database
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![CI](https://github.com/farjs/better-sqlite3-wrapper/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/farjs/better-sqlite3-wrapper/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amain)
[![npm version](https://img.shields.io/npm/v/@farjs/better-sqlite3-wrapper)](https://www.npmjs.com/package/@farjs/better-sqlite3-wrapper)## @farjs/better-sqlite3-wrapper
Thin api wrapper around [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
and [bun:sqlite](https://bun.sh/docs/api/sqlite) to allow cross- runtime/engine usage.It exposes only [a subset](./index.d.ts) of `better-sqlite3` api because not everything
is available in `bun:sqlite`.For example, since `run` returns `undefined` you can use the following queries to get
`changes` and/or `lastInsertRowid`:```javascript
const changes = db.prepare("SELECT changes() AS changes;").get().changes;
const lastInsertRowId = db.prepare("SELECT last_insert_rowid() AS id;").get().id;
```Also, since `db.pragma` is not available in `bun:sqlite`, you can run:
```javascript
// non-transactional
db.prepare("PRAGMA foreign_keys = ON;").run();
```