Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
iyobo committed Aug 20, 2024
1 parent 5bce18a commit 270cc77
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/PouchORM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class PouchORM {

/**
* A map of active sync operations
* from -> to -> SyncOp reference
*/
public static activeSyncOperations: Record<string, Record<string, Sync<IModel>>> = {};

Expand Down
7 changes: 4 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import PouchDB from 'pouchdb';
import PouchFind from 'pouchdb-find';
import { IModel } from './types';

PouchDB.plugin(PouchFind);

export function getPouchDBWithPlugins() {
return PouchDB;
}

export function UpsertHelper(item: any) {
export function UpsertHelper<T extends IModel>(item: T) {
return {
merge: (existing: any) => ({...existing, ...item, _rev: existing._rev}),
replace: (existing: any) => ({...item, _rev: existing._rev})
merge: (existing: T) => ({...existing, ...item, _rev: existing._rev}),
replace: (existing: T) => ({...item, _rev: existing._rev})
};
}
2 changes: 1 addition & 1 deletion src/tests/PouchCollection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('PouchCollection Instance', () => {
it('validation of class Model properties', async () => {
const a = new Account({
name: 'Spyder',
age: '32' as any
age: '32' as unknown as number
});
let error: ValidationError[];

Expand Down

0 comments on commit 270cc77

Please sign in to comment.