dexie-cloud-common
Advanced tools
Comparing version 1.0.17 to 1.0.18
import { setByKeyPath } from "../utils.js"; | ||
export function applyOperation(target, table, op) { | ||
const tbl = target[table] || (target[table] = {}); | ||
const keys = op.keys.map(key => typeof key === 'string' ? key : JSON.stringify(key)); | ||
switch (op.type) { | ||
@@ -8,3 +9,3 @@ case "insert": | ||
case "upsert": | ||
op.keys.forEach((key, idx) => { | ||
keys.forEach((key, idx) => { | ||
tbl[key] = { | ||
@@ -18,3 +19,3 @@ type: "ups", | ||
case "modify": { | ||
op.keys.forEach((key, idx) => { | ||
keys.forEach((key, idx) => { | ||
const changeSpec = op.type === "update" | ||
@@ -51,3 +52,3 @@ ? op.changeSpecs[idx] | ||
case "delete": | ||
op.keys.forEach((key) => { | ||
keys.forEach((key) => { | ||
tbl[key] = { | ||
@@ -54,0 +55,0 @@ type: "del", |
@@ -9,3 +9,3 @@ import { DBOperationsSet } from "../DBOperationsSet.js"; | ||
*/ | ||
export declare function toDBOperationSet(inSet: DBKeyMutationSet): DBOperationsSet; | ||
export declare function toDBOperationSet(inSet: DBKeyMutationSet): DBOperationsSet<string>; | ||
//# sourceMappingURL=toDBOperationSet.d.ts.map |
@@ -0,1 +1,2 @@ | ||
export declare type DBOpPrimaryKey = string | (string | number)[]; | ||
declare const enum DBCoreRangeType { | ||
@@ -18,19 +19,19 @@ Equal = 1, | ||
} | ||
export declare type DBOperation = DBInsertOperation | DBUpsertOperation | DBUpdateOperation | DBModifyOperation | DBDeleteOperation; | ||
export interface DBOperationCommon { | ||
export declare type DBOperation<PK = DBOpPrimaryKey> = DBInsertOperation<PK> | DBUpsertOperation<PK> | DBUpdateOperation<PK> | DBModifyOperation<PK> | DBDeleteOperation<PK>; | ||
export interface DBOperationCommon<PK = DBOpPrimaryKey> { | ||
rev?: number; | ||
ts?: number | null; | ||
keys: any[]; | ||
keys: PK[]; | ||
txid?: string | null; | ||
userId?: string | null; | ||
} | ||
export interface DBInsertOperation extends DBOperationCommon { | ||
export interface DBInsertOperation<PK = DBOpPrimaryKey> extends DBOperationCommon<PK> { | ||
type: "insert"; | ||
values: any[]; | ||
} | ||
export interface DBUpsertOperation extends DBOperationCommon { | ||
export interface DBUpsertOperation<PK = DBOpPrimaryKey> extends DBOperationCommon<PK> { | ||
type: "upsert"; | ||
values: any[]; | ||
} | ||
export interface DBUpdateOperation extends DBOperationCommon { | ||
export interface DBUpdateOperation<PK = DBOpPrimaryKey> extends DBOperationCommon<PK> { | ||
type: "update"; | ||
@@ -41,3 +42,3 @@ changeSpecs: { | ||
} | ||
export interface DBModifyOperation extends DBOperationCommon { | ||
export interface DBModifyOperation<PK = DBOpPrimaryKey> extends DBOperationCommon<PK> { | ||
type: "modify"; | ||
@@ -52,3 +53,3 @@ criteria: { | ||
} | ||
export interface DBDeleteOperation extends DBOperationCommon { | ||
export interface DBDeleteOperation<PK = DBOpPrimaryKey> extends DBOperationCommon<PK> { | ||
type: "delete"; | ||
@@ -55,0 +56,0 @@ criteria?: { |
@@ -1,6 +0,6 @@ | ||
import { DBOperation } from "./DBOperation.js"; | ||
export declare type DBOperationsSet = Array<{ | ||
import { DBOperation, DBOpPrimaryKey } from "./DBOperation.js"; | ||
export declare type DBOperationsSet<PK = DBOpPrimaryKey> = Array<{ | ||
table: string; | ||
muts: DBOperation[]; | ||
muts: DBOperation<PK>[]; | ||
}>; | ||
//# sourceMappingURL=DBOperationsSet.d.ts.map |
@@ -9,3 +9,3 @@ import { DBOperationsSet } from './DBOperationsSet.js'; | ||
schema: DexieCloudSchema; | ||
changes: DBOperationsSet; | ||
changes: DBOperationsSet<string>; | ||
rejections: { | ||
@@ -12,0 +12,0 @@ name: string; |
{ | ||
"name": "dexie-cloud-common", | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"description": "Library for shared code between dexie-cloud-addon, dexie-cloud (CLI) and dexie-cloud-server", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -13,5 +13,6 @@ { | ||
"declarationMap": true, | ||
"allowSyntheticDefaultImports": true | ||
"allowSyntheticDefaultImports": true, | ||
"composite": true | ||
}, | ||
"include": ["./src"] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55317
72
670