brinedb
v1.0.2
Published
SeaORM wrapper for NodeJS, providing basic key/value storage in sqlite/postgres/mysql
Downloads
3
Maintainers
Readme
BrineDB
SeaORM wrapper for NodeJS, providing basic key/value storage in SQLite/Postgres/MySQL/MariaDB.
Table of contents
Getting Started
Installation
To install and set up the library, run:
$ yarn add brinedb
Or if you prefer npm:
$ npm i brinedb
Quick Start
const { Brine } = require('brinedb');
// 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');
// MariaDB
const brinedb = new Brine('mariadb://user:pass@localhost:3306/dbname');
// MySQL
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');
Typescript
This library is written in Typescript and includes type definitions. Here is an example that will be typed correctly:
import { Brine } from 'brinedb';
type Value = { hello: string }
const brinedb = new Brine<Value>('sqlite::memory:');
await brinedb.set('key', { hello: 'world' });
const decoded = brinedb.get('key'); // Correctly typed
Development
Prerequisites
This project requires NodeJS (version 20 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)
Building the entire package
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/
Contributing
- 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 :sunglasses:
Built With
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- DanCodes - @dan-online - [email protected]
License
MIT License © DanCodes