DbSet Declaration - Agrejus/pouchdb-entity-fabric GitHub Wiki
To interact with a PouchDB database, a DbSet must be declared within a DataContext. DbSet declaration is done via the DbSet Fluent API, which offers a lot of customization if needed. To declare a basic DbSet, there must be an enum of allowed collections, a document type, and a context to create the DbSet
import { DataContext } from 'pouchdb-entity-fabric';
export enum DocumentTypes {
MyFirstDocument = "MyFirstDocument"
}
interface IMyFirstEntity extends IDbRecord<DocumentTypes> {
propertyOne: string;
propertyTwo: string;
}
export class PouchDbDataContext extends DataContext<DocumentTypes> {
myFirstDbSet = this.dbset().default<IMyFirstEntity>(DocumentTypes.MyFirstDocument).create();
}