SeaORM wrapper for NodeJS, providing basic key/value storage in SQLite/Postgres/MySQL/MariaDB.
To install and set up the library, run:
$ yarn add @brine-db/brine
Or if you prefer npm:
$ npm i @brine-db/brine
const { Brine } = require('@brine-db/brine');
// SQLite
const brinedb = new Brine('sqlite::memory:');
const brinedb = new Brine('sqlite:/path/to/database.sqlite');
// Postgres
const brinedb = new Brine('postgres://user:pass@localhost:5432/dbname');
// MySQL/MariaDB
const brinedb = new Brine('mysql://user:pass@localhost:3306/dbname');
// Initialize the database (also runs migrations)
await brinedb.init();
// Set a value
await brinedb.set('key', { hello: 'world' });
// Get a value
const value = await brinedb.get('key');
This library is written in Typescript and includes type definitions. Here is an example that will be typed correctly:
import { Brine } from '@brine-db/brine';
type Value = { hello: string }
const brinedb = new Brine<Value>('sqlite::memory:');
await brinedb.set('key', { hello: 'world' });
const decoded = brinedb.get('key');
typeof decoded.hello; // string
This project requires NodeJS (version 18 or later) and yarn. Node and Yarn are really easy to install. To make sure you have them available on your machine, try running the following command.
$ yarn -v && node -v && rustc --version # Example output
3.6.3
v20.11.1
rustc 1.78.0-nightly (4a0cc881d 2024-03-11)
Requirement: Rust is installed on your machine.
$ yarn build
This task will create a distribution version of the project
inside your local dist/
folder and output a binary in native/
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Add your changes:
git add .
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request 😎
We use SemVer for versioning. For the versions available, see the tags on this repository.
- DanCodes - @dan-online - [email protected]
MIT License © DanCodes