jsondb-sequelize-like
v0.4.2
Published
⚠️ Note: This project is not affiliated with Sequelize. It’s simply inspired by its syntax and modeling philosophy to make transitions easier.
Readme
jsondb-sequelize-like – A lightweight JSON-based database with Sequelize-like syntax
⚠️ Note: This project is not affiliated with Sequelize. It’s simply inspired by its syntax and modeling philosophy to make transitions easier.
Documentation availables in docs folder
jsondb-sequelize-like is a minimalist, file-based JSON database engine inspired by Sequelize.
It stores your data in flat .json files, supports typed schemas, append-only logs, validation, and a syntax similar to popular ORMs.
Ideal for embedded systems, CLIs, quick prototyping, or educational use.
🚀 Features
- 💾 Flat-file JSON storage
- 🧠 In-memory cache with periodic snapshot (fast processing in history and cache, slow process of storing trigger periodically)
- ✍️ Append-only sync history for safe writes (concurrency-free)
- 🔍 SQL-like querying:
where,like,is, etc. - 🧱 Schema definition with
DataTypes,unique,validation, etc. - 🎯 Auto-incrementing primary keys
- 🗓️ Auto save createdAt and updatedAt
- ✅ Inspired by Sequelize syntax
- 🔒 No external dependencies
Watch our Sequelize Compatibility file for more information or compatibiliy check.
All syntax should be the same as sequelize v6, so you can refer to their documentation to use this package.
📦 Installation
npm install jsondb-sequelize-like🛠️ Basic Usage
1. Define a model
import Jdb, { DataTypes } from 'jsondb-sequelize-like';
const db = new Jdb();
const User = db.define('user', {
email: {
type: DataTypes.STRING(255),
unique: true,
validate: /.*@.*/
},
password: {
type: DataTypes.STRING(255)
}
});2. Create records
User.create({
email: '[email protected]',
password: '123456'
});3. Query data
const allUsers = User.findAll(); // returns all users
const filtered = User.findOne({
where: {
email: { like: '%@example.com' }
}
});4. Validate types and uniqueness
User.create({
email: 'invalid-email', // fails regex validation
password: 123456 // fails string type check
});🧪 Schema options (current support)
type: required — one of DataTypesunique: boolean — ensures uniqueness in the datasetvalidate: validates the input on insertallowNull: force a field to have a valuedefaultValue: default value for a field if not specify- ...
💡 Philosophy
The goal of jsondb-sequelize-like is to offer a zero-dependency, file-based DB that mirrors the experience of Sequelize — so you can:
- prototype fast,
- ship lightweight apps (embedded, CLI, offline tools),
- and switch to Sequelize + Any SQL Database supported by sequelize later without rewriting your models and queries at all.
📁 Data Storage Structure
project/
├── data/
│ ├── table.json ← snapshot (state)
│ └── history/
│ └── history.txt ← append-only logSnapshots are periodically written to disk and logs are replayed if needed.
📄 License
Custom : see LICENSE.md
🙌 Author
Aurélien Vaast – GitHub - trainingdev.fr - npm -
