chori
v0.1.0
Published
A fluid schema ORM
Readme
chori
chori is an Object Relational Mapping (ORM) library for NodeJS that supports fluid-schemas.
Install
npm install choriExample
import chori from 'chori';
const db = chori.setup({sqlite: "foo.db"});
async function createBook(title, year) {
const book = db.dispense('book', { title, year });
if (title.includes("1984")) {
book.banned = true;
book.bannedReason = "Moved to memory hole";
}
await db.store(book);
}After running the foo.db file will contain an sqlite3 database, where if we
export the schema we would get:
CREATE TABLE book (
id INT NOT NULL AUTOINCREMENT,
title TEXT NULL,
year INT NULL
)Once we create a book with 1984 in the title we trigger the code that uses the
banned and bannedReason columns. This will cause the schema to be modified
at runtime to have the new columns.
Note that the id column is always present and used internally.
