Registry / database / localstorage-orm

localstorage-orm

JSON →
library1.1.0jsnpmunverified

localstorage-orm is a lightweight TypeScript ORM for browser localStorage that provides a model-based CRUD interface with schema validation, timestamps, soft deletes, and reference/population support. Current stable version is 1.1.0. It uses a simple builder pattern for records and supports find/findById methods. Key differentiators: direct localStorage persistence with no backend required, TypeScript-first with type safety, and built-in reference population for relational data management within the browser. Release cadence is irregular; latest update was September 2024.

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.

Package is ESM-only; CommonJS require may cause runtime errors. Ensure 'type':'module' in package.json or use .mjs extension.

import { Model } from 'localstorage-orm'

Schema is a named export, not default. Also required as base interface for model schemas.

import { Schema } from 'localstorage-orm'

Constructor requires a string model name and optional settings object. The generic type parameter should extend Schema.

import { Model } from 'localstorage-orm'; new Model<Person>('person')

Create a model, build a record, persist, fetch, update, and delete using Model and Schema.

import { Model, Schema } from 'localstorage-orm'; interface Person extends Schema { name: string; age: number; } const personModel = new Model<Person>('person'); const person = personModel.build(); person.name = 'John Doe'; person.age = 30; person.save(); const all = personModel.list(); console.log(all.length); // 1 const found = personModel.findOne({ name: 'John Doe' }); if (found) { found.age = 31; found.save(); found.delete(); }
Debug
Known footguns
gotchaModel constructor expects a generic type that extends Schema. Failing to extend Schema will cause TypeScript compilation errors.
breakingLocalStorage is synchronous and blocking. Large datasets may cause UI jank. No async operations supported.
gotchaThe build() method returns a new instance but does NOT automatically save. You must call .save() on it or use create() for immediate persistence.
deprecatedThe get() method is an alias for findById(). No deprecation notice yet, but prefer findById() for clarity.
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
8 hits · last 30 days
gptbot
3
bingbot
1
ahrefsbot
1
Resources