Registry / database / functional-models-orm-json

functional-models-orm-json

JSON →
library3.0.2jsnpmunverified

An ORM adapter for functional-models that stores data in JSON files. Current version 3.0.2. This package implements the datastoreAdapter interface from functional-models, allowing you to use a JSON file as a database backend. It is designed for small-scale, file-based persistence, often used in prototyping, local development, or low-traffic applications. Unlike SQLite or LevelDB, it stores the entire dataset in a single JSON file, which is simple to inspect and version-control. Release cadence is irregular as it is part of the functional-models ecosystem.

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Named ESM export. CommonJS require returns the module object; you must destructure or use .datastoreAdapter.

import { datastoreAdapter } from 'functional-models-orm-json'

CommonJS named export via destructuring. No default export.

const { datastoreAdapter } = require('functional-models-orm-json')

Shows how to set up the ORM with a JSON file, define a model, and create/save a record.

const { jsonClient } = require('jsondb'); const { createOrm } = require('functional-models'); const { datastoreAdapter } = require('functional-models-orm-json'); const filePath = './data.json'; const adapter = datastoreAdapter({ filePath }); const orm = createOrm({ datastoreAdapter: adapter }); const User = orm.defineModel({ name: 'user', attributes: { id: { type: 'string', required: true }, name: { type: 'string', required: true }, email: { type: 'string' }, }, }); const user = User.create({ id: '1', name: 'Alice', email: 'alice@example.com' }); user.save().then(() => console.log('User saved'));
Debug
Known footguns
gotchaJSON file must exist and be a valid JSON array. If file is empty or missing, adapter fails.
gotchaAll data is loaded into memory on startup. Large files may cause performance issues.
gotchaNo concurrent write support; multiple writes can corrupt the file.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
2
mj12bot
1
Resources