Stable collection identity
Choose the collection name stored with each document. Production builds and class renames cannot change it.
PouchORM adds models, named collections, validation, query helpers, and synchronization management while keeping the PouchDB database available when you need it.
import { IModel, PouchCollection } from "pouchorm";
interface Person extends IModel {
name: string;
age: number;
}
class People extends PouchCollection<Person> {
constructor() {
super({
database: "app-data",
// Stored with each document, so keep this name stable.
collection: "people",
});
}
}
const people = new People();
// No _id means upsert creates a document with a UUIDv7.
const ada = await people.upsert({
name: "Ada Lovelace",
age: 36,
});
Choose the collection name stored with each document. Production builds and class renames cannot change it.
Create and update through one method, retain PouchDB revisions, validate models, and handle conflicts without changing caller-owned objects.
Use the underlying database for attachments, plugins, and platform-specific adapters when the collection API is not the right level.
Version 5 requires stable collection names, a PouchDB peer dependency, and explicit validator registration.