Merging Documents - Agrejus/pouchdb-entity-fabric GitHub Wiki
Sometimes, there are documents that have many properties to be merged or set. Instead of doing this long hand, the static merge function can be used.
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();
}
const context = new PouchDbDataContext();
const myDocument = await context.myFirstDbSet.first();
DataContext.merge(myDocument, { propertyOne: "newValue", propertyTwo: "otherNewValue" });