🐧 Antarctic-friendly ORM for Node
Photo (c) by Jason Auch
Adelia is meant to be a fast, simple, promise-based ORM for Node, loosely inspired to Martin Fowler's ActiveRecord pattern popularized by Ruby on Rails. Due to the async IO nature of Node and DB clients, the API must be async. Adelia uses Promises to offer a clean, uncluttered API that's easy to compose and reason about.
Set these environment variables in your script:
DBone of the supported databases:
Set these variables to configure Adelia to use a MySQL database server:
MYSQL_HOSThost of the MySQL database server.
MYSQL_PORTport of the MySQL database server.
MYSQL_USERusername to connect to the MySQL database server.
MYSQL_PASSWORDpassword of the user of the MySQL database server.
MYSQL_DBname of the MySQL database.
This assumes you already have a MySQL server to use. For local development, see the Development section below.
Set this variable to configure Adelia to use a SQLite database:
SQLITE_DBpath to the SQLite database file.
Adelia has a concise, promise-based API that allows you to perform chained operations to query and fetch model objects, access their properties, persist, and delete them. Here's an example:
const Model = Model;// Creates a specialized model classconst Penguin = Model;// Instantiates a penguinconst emperor =species: 'Emperor';let emperor_id;// Saves the penguin to DBemperor;// Fetches a model from the DBPenguin;// => My species is Emperor
- MySQL support: STABLE
- SQLite support: EXPERIMENTAL
MySQL support is currently stable, with some known issues. SQLite support is currently experimental. Tests are failing locally and in TravisCI. If you'd like to use Adelia on SQLite and can contribute fixes and enhancements, please submit a PR!
Thank you for your interest in Adelia! Feel free to open issues or submit a PR. See the Contributing Guidelines for detailed instructions.
Adelia is a Node module. If you are unsure what to do, follow these steps:
Installing a local MySQL server
The default test target should be sufficient for most contributors:
If you want to run tests for MySQL alone, run:
npm run test-mysql
There are also SQLite specific tests:
npm run test-sqlite
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Copyright (c) 2016, Claudio Procida