@webiny/db-dynamodb 0.0.0-unstable.7f63ea0744 → 0.0.0-unstable.8acc9e8892
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BatchProcess.d.ts +1 -1
- package/index.d.ts +2 -0
- package/index.js +24 -1
- package/index.js.map +1 -1
- package/package.json +9 -9
- package/types.d.ts +8 -0
- package/types.js.map +1 -1
- package/utils/createStandardEntity.d.ts +2 -0
- package/utils/createStandardEntity.js +34 -0
- package/utils/createStandardEntity.js.map +1 -0
- package/utils/query.d.ts +6 -1
- package/utils/query.js +22 -3
- package/utils/query.js.map +1 -1
package/BatchProcess.d.ts
CHANGED
|
@@ -42,6 +42,6 @@ declare class BatchProcess {
|
|
|
42
42
|
addBatchDelete(args: AddBatchOperationArgs): AddBatchOperationResponse;
|
|
43
43
|
addBatchGet(args: AddBatchOperationArgs): AddBatchOperationResponse;
|
|
44
44
|
allOperationsAdded(): boolean;
|
|
45
|
-
startExecution(): import("aws-sdk/lib/request").Request<DocumentClient.
|
|
45
|
+
startExecution(): import("aws-sdk/lib/request").Request<DocumentClient.BatchWriteItemOutput, import("aws-sdk/lib/error").AWSError> | import("aws-sdk/lib/request").Request<DocumentClient.BatchGetItemOutput, import("aws-sdk/lib/error").AWSError>;
|
|
46
46
|
}
|
|
47
47
|
export default BatchProcess;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -4,10 +4,33 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
var _exportNames = {
|
|
8
|
+
DynamoDbDriver: true,
|
|
9
|
+
DbItem: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "DbItem", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _types.DbItem;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
7
17
|
Object.defineProperty(exports, "DynamoDbDriver", {
|
|
8
18
|
enumerable: true,
|
|
9
19
|
get: function () {
|
|
10
20
|
return _DynamoDbDriver.default;
|
|
11
21
|
}
|
|
12
22
|
});
|
|
13
|
-
var _DynamoDbDriver = _interopRequireDefault(require("./DynamoDbDriver"));
|
|
23
|
+
var _DynamoDbDriver = _interopRequireDefault(require("./DynamoDbDriver"));
|
|
24
|
+
var _createStandardEntity = require("./utils/createStandardEntity");
|
|
25
|
+
Object.keys(_createStandardEntity).forEach(function (key) {
|
|
26
|
+
if (key === "default" || key === "__esModule") return;
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
+
if (key in exports && exports[key] === _createStandardEntity[key]) return;
|
|
29
|
+
Object.defineProperty(exports, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return _createStandardEntity[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
var _types = require("./types");
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\n\nexport { DynamoDbDriver };\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\nexport * from \"./utils/createStandardEntity\";\nexport { DbItem } from \"./types\";\n\nexport { DynamoDbDriver };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/db-dynamodb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.8acc9e8892",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"author": "Webiny Ltd",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/api": "0.0.0-unstable.
|
|
14
|
-
"@webiny/db": "0.0.0-unstable.
|
|
15
|
-
"@webiny/error": "0.0.0-unstable.
|
|
16
|
-
"@webiny/handler-db": "0.0.0-unstable.
|
|
17
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
13
|
+
"@webiny/api": "0.0.0-unstable.8acc9e8892",
|
|
14
|
+
"@webiny/db": "0.0.0-unstable.8acc9e8892",
|
|
15
|
+
"@webiny/error": "0.0.0-unstable.8acc9e8892",
|
|
16
|
+
"@webiny/handler-db": "0.0.0-unstable.8acc9e8892",
|
|
17
|
+
"@webiny/plugins": "0.0.0-unstable.8acc9e8892",
|
|
18
18
|
"date-fns": "2.29.3",
|
|
19
19
|
"dot-prop": "6.0.1",
|
|
20
20
|
"fuse.js": "6.6.2",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@babel/cli": "^7.19.3",
|
|
26
26
|
"@babel/core": "^7.19.3",
|
|
27
27
|
"@types/is-number": "^7.0.2",
|
|
28
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
29
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
28
|
+
"@webiny/cli": "^0.0.0-unstable.8acc9e8892",
|
|
29
|
+
"@webiny/project-utils": "^0.0.0-unstable.8acc9e8892",
|
|
30
30
|
"dynamodb-toolbox": "^0.3.5",
|
|
31
31
|
"jest": "^28.1.0",
|
|
32
32
|
"jest-dynalite": "^3.2.0",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"build": "yarn webiny run build",
|
|
43
43
|
"watch": "yarn webiny run watch"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8acc9e8892842cabb3980ce0b6432fde55968d5b"
|
|
46
46
|
}
|
package/types.d.ts
CHANGED
|
@@ -55,4 +55,12 @@ export interface QueryKey {
|
|
|
55
55
|
}
|
|
56
56
|
export declare type QueryKeys = QueryKey[];
|
|
57
57
|
export declare type QuerySort = Record<string, -1 | 1>;
|
|
58
|
+
export declare type DbItem<TData extends Record<string, any> = Record<string, any>> = {
|
|
59
|
+
PK: string;
|
|
60
|
+
SK: string;
|
|
61
|
+
GSI1_PK: string;
|
|
62
|
+
GSI1_SK: string;
|
|
63
|
+
TYPE: string;
|
|
64
|
+
data: TData;
|
|
65
|
+
};
|
|
58
66
|
export {};
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface OperatorArgs {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\n\ninterface CanProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n}\n\ninterface ProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n processStatement: any;\n}\n\nexport interface Operator {\n canProcess: ({ key }: CanProcessArgs) => boolean;\n process: ({ key, value, args }: ProcessArgs) => void;\n}\n\n/**\n * We use this definition to search for a value in any given field that was passed.\n * It works as an \"OR\" condition.\n */\nexport interface DynamoDbContainsFilter {\n fields: string[];\n value: string;\n}\n\nexport interface ProcessStatementArgsParam {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\nexport interface ProcessStatementQueryParam {\n [key: string]: any;\n}\nexport interface ProcessStatementParams {\n args: ProcessStatementArgsParam;\n query: ProcessStatementQueryParam;\n}\n\nexport interface ProcessStatementCallable {\n (params: ProcessStatementParams): void;\n}\n\nexport interface Query {\n [key: string]: string;\n}\nexport interface QueryKeyField {\n name: string;\n}\nexport interface QueryKey {\n fields: QueryKeyField[];\n primary?: boolean;\n unique?: boolean;\n name: string;\n}\nexport type QueryKeys = QueryKey[];\n\nexport type QuerySort = Record<string, -1 | 1>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface OperatorArgs {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\n\ninterface CanProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n}\n\ninterface ProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n processStatement: any;\n}\n\nexport interface Operator {\n canProcess: ({ key }: CanProcessArgs) => boolean;\n process: ({ key, value, args }: ProcessArgs) => void;\n}\n\n/**\n * We use this definition to search for a value in any given field that was passed.\n * It works as an \"OR\" condition.\n */\nexport interface DynamoDbContainsFilter {\n fields: string[];\n value: string;\n}\n\nexport interface ProcessStatementArgsParam {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\nexport interface ProcessStatementQueryParam {\n [key: string]: any;\n}\nexport interface ProcessStatementParams {\n args: ProcessStatementArgsParam;\n query: ProcessStatementQueryParam;\n}\n\nexport interface ProcessStatementCallable {\n (params: ProcessStatementParams): void;\n}\n\nexport interface Query {\n [key: string]: string;\n}\nexport interface QueryKeyField {\n name: string;\n}\nexport interface QueryKey {\n fields: QueryKeyField[];\n primary?: boolean;\n unique?: boolean;\n name: string;\n}\nexport type QueryKeys = QueryKey[];\n\nexport type QuerySort = Record<string, -1 | 1>;\n\nexport type DbItem<TData extends Record<string, any> = Record<string, any>> = {\n PK: string;\n SK: string;\n GSI1_PK: string;\n GSI1_SK: string;\n TYPE: string;\n data: TData;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createStandardEntity = void 0;
|
|
7
|
+
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
8
|
+
const createStandardEntity = (table, name) => {
|
|
9
|
+
return new _dynamodbToolbox.Entity({
|
|
10
|
+
name,
|
|
11
|
+
table,
|
|
12
|
+
attributes: {
|
|
13
|
+
PK: {
|
|
14
|
+
partitionKey: true
|
|
15
|
+
},
|
|
16
|
+
SK: {
|
|
17
|
+
sortKey: true
|
|
18
|
+
},
|
|
19
|
+
GSI1_PK: {
|
|
20
|
+
type: "string"
|
|
21
|
+
},
|
|
22
|
+
GSI1_SK: {
|
|
23
|
+
type: "string"
|
|
24
|
+
},
|
|
25
|
+
TYPE: {
|
|
26
|
+
type: "string"
|
|
27
|
+
},
|
|
28
|
+
data: {
|
|
29
|
+
type: "map"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.createStandardEntity = createStandardEntity;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createStandardEntity","table","name","Entity","attributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","data"],"sources":["createStandardEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\n\nexport const createStandardEntity = (table: Table, name: string): Entity<any> => {\n return new Entity({\n name,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n }\n }\n });\n};\n"],"mappings":";;;;;;AAAA;AAEO,MAAMA,oBAAoB,GAAG,CAACC,KAAY,EAAEC,IAAY,KAAkB;EAC7E,OAAO,IAAIC,uBAAM,CAAC;IACdD,IAAI;IACJD,KAAK;IACLG,UAAU,EAAE;MACRC,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/utils/query.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ export declare type DbItem<T> = T & {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare const queryOne: <T>(params: QueryOneParams) => Promise<DbItem<T> | null>;
|
|
29
29
|
/**
|
|
30
|
-
* Will run the query to fetch the results no matter how
|
|
30
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
31
31
|
*/
|
|
32
32
|
export declare const queryAll: <T>(params: QueryAllParams) => Promise<DbItem<T>[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
35
|
+
* Results of each iteration will be passed to the provided callback
|
|
36
|
+
*/
|
|
37
|
+
export declare const queryAllWithCallback: <T>(params: QueryAllParams, callback: (items: DbItem<T>[]) => Promise<void>) => Promise<void>;
|
package/utils/query.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.queryOne = exports.queryAll = void 0;
|
|
7
|
+
exports.queryOne = exports.queryAllWithCallback = exports.queryAll = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
10
|
/**
|
|
@@ -79,7 +79,7 @@ const queryOne = async params => {
|
|
|
79
79
|
return item ? item : null;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* Will run the query to fetch the results no matter how
|
|
82
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
83
83
|
*/
|
|
84
84
|
exports.queryOne = queryOne;
|
|
85
85
|
const queryAll = async params => {
|
|
@@ -97,4 +97,23 @@ const queryAll = async params => {
|
|
|
97
97
|
}
|
|
98
98
|
return items;
|
|
99
99
|
};
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
103
|
+
* Results of each iteration will be passed to the provided callback
|
|
104
|
+
*/
|
|
105
|
+
exports.queryAll = queryAll;
|
|
106
|
+
const queryAllWithCallback = async (params, callback) => {
|
|
107
|
+
let results;
|
|
108
|
+
let previousResult = undefined;
|
|
109
|
+
while (results = await query((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
110
|
+
previous: previousResult
|
|
111
|
+
}))) {
|
|
112
|
+
if (!results.result) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
await callback(results.items);
|
|
116
|
+
previousResult = results.result;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
exports.queryAllWithCallback = queryAllWithCallback;
|
package/utils/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["query","params","entity","previous","partitionKey","options","result","next","items","Items","Array","isArray","WebinyError","queryOne","limit","item","shift","queryAll","results","previousResult","undefined","push"],"sources":["query.ts"],"sourcesContent":["import { queryOptions as DynamoDBToolboxQueryOptions } from \"dynamodb-toolbox/dist/classes/Table\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\n\nexport interface QueryAllParams {\n entity: Entity<any>;\n partitionKey: string;\n options?: DynamoDBToolboxQueryOptions;\n}\n\nexport interface QueryOneParams extends QueryAllParams {\n options?: Omit<DynamoDBToolboxQueryOptions, \"limit\">;\n}\n\nexport interface QueryParams extends QueryAllParams {\n previous?: any;\n}\n\nexport interface QueryResult<T> {\n result: any | null;\n items: T[];\n}\n\nexport type DbItem<T> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n};\n\n/**\n * Will run query only once. Pass the previous to run the query again to fetch new data.\n * It returns the result and the items it found.\n * Result is required to fetch the items that were not fetched in the previous run.\n */\nconst query = async <T>(params: QueryParams): Promise<QueryResult<T>> => {\n const { entity, previous, partitionKey, options } = params;\n let result;\n /**\n * In case there is no previous result we must make a new query.\n * This is the first query on the given partition key.\n */\n if (!previous) {\n result = await entity.query(partitionKey, options);\n } else if (typeof previous.next === \"function\") {\n /**\n * In case we have a previous result and it has a next method, we run it.\n * In case result of the next method is false, it means it has nothing else to read\n * and we return a null to keep the query from repeating.\n */\n result = await previous.next();\n if (result === false) {\n return {\n result: null,\n items: []\n };\n }\n } else {\n /**\n * This could probably never happen but keep it here just in case to break the query loop.\n * Basically, either previous does not exist or it exists and it does not have the next method\n * and at that point a result returned will be null and loop should not start again.\n */\n return {\n result: null,\n items: []\n };\n }\n /**\n * We expect the result to contain an Items array and if not, something went wrong, very wrong.\n */\n if (!result || !result.Items || !Array.isArray(result.Items)) {\n throw new WebinyError(\n \"Error when querying for content entries - no result.\",\n \"QUERY_ERROR\",\n {\n partitionKey,\n options\n }\n );\n }\n return {\n result,\n items: result.Items\n };\n};\n/**\n * Will run the query to fetch the first possible item from the database.\n */\nexport const queryOne = async <T>(params: QueryOneParams): Promise<DbItem<T> | null> => {\n const { items } = await query<DbItem<T>>({\n ...params,\n options: {\n ...(params.options || {}),\n limit: 1\n }\n });\n const item = items.shift();\n return item ? item : null;\n};\n/**\n * Will run the query to fetch the results no matter how
|
|
1
|
+
{"version":3,"names":["query","params","entity","previous","partitionKey","options","result","next","items","Items","Array","isArray","WebinyError","queryOne","limit","item","shift","queryAll","results","previousResult","undefined","push","queryAllWithCallback","callback"],"sources":["query.ts"],"sourcesContent":["import { queryOptions as DynamoDBToolboxQueryOptions } from \"dynamodb-toolbox/dist/classes/Table\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\n\nexport interface QueryAllParams {\n entity: Entity<any>;\n partitionKey: string;\n options?: DynamoDBToolboxQueryOptions;\n}\n\nexport interface QueryOneParams extends QueryAllParams {\n options?: Omit<DynamoDBToolboxQueryOptions, \"limit\">;\n}\n\nexport interface QueryParams extends QueryAllParams {\n previous?: any;\n}\n\nexport interface QueryResult<T> {\n result: any | null;\n items: T[];\n}\n\nexport type DbItem<T> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n};\n\n/**\n * Will run query only once. Pass the previous to run the query again to fetch new data.\n * It returns the result and the items it found.\n * Result is required to fetch the items that were not fetched in the previous run.\n */\nconst query = async <T>(params: QueryParams): Promise<QueryResult<T>> => {\n const { entity, previous, partitionKey, options } = params;\n let result;\n /**\n * In case there is no previous result we must make a new query.\n * This is the first query on the given partition key.\n */\n if (!previous) {\n result = await entity.query(partitionKey, options);\n } else if (typeof previous.next === \"function\") {\n /**\n * In case we have a previous result and it has a next method, we run it.\n * In case result of the next method is false, it means it has nothing else to read\n * and we return a null to keep the query from repeating.\n */\n result = await previous.next();\n if (result === false) {\n return {\n result: null,\n items: []\n };\n }\n } else {\n /**\n * This could probably never happen but keep it here just in case to break the query loop.\n * Basically, either previous does not exist or it exists and it does not have the next method\n * and at that point a result returned will be null and loop should not start again.\n */\n return {\n result: null,\n items: []\n };\n }\n /**\n * We expect the result to contain an Items array and if not, something went wrong, very wrong.\n */\n if (!result || !result.Items || !Array.isArray(result.Items)) {\n throw new WebinyError(\n \"Error when querying for content entries - no result.\",\n \"QUERY_ERROR\",\n {\n partitionKey,\n options\n }\n );\n }\n return {\n result,\n items: result.Items\n };\n};\n/**\n * Will run the query to fetch the first possible item from the database.\n */\nexport const queryOne = async <T>(params: QueryOneParams): Promise<DbItem<T> | null> => {\n const { items } = await query<DbItem<T>>({\n ...params,\n options: {\n ...(params.options || {}),\n limit: 1\n }\n });\n const item = items.shift();\n return item ? item : null;\n};\n/**\n * Will run the query to fetch the results no matter how many iterations it needs to go through.\n */\nexport const queryAll = async <T>(params: QueryAllParams): Promise<DbItem<T>[]> => {\n const items: DbItem<T>[] = [];\n let results: QueryResult<DbItem<T>>;\n let previousResult: any = undefined;\n while ((results = await query({ ...params, previous: previousResult }))) {\n items.push(...results.items);\n if (!results.result) {\n return items;\n }\n previousResult = results.result;\n }\n return items;\n};\n\n/**\n * Will run the query to fetch the results no matter how many iterations it needs to go through.\n * Results of each iteration will be passed to the provided callback\n */\nexport const queryAllWithCallback = async <T>(\n params: QueryAllParams,\n callback: (items: DbItem<T>[]) => Promise<void>\n): Promise<void> => {\n let results: QueryResult<DbItem<T>>;\n let previousResult: any = undefined;\n while ((results = await query({ ...params, previous: previousResult }))) {\n if (!results.result) {\n break;\n }\n await callback(results.items);\n previousResult = results.result;\n }\n};\n"],"mappings":";;;;;;;;AACA;AA8BA;AACA;AACA;AACA;AACA;AACA,MAAMA,KAAK,GAAG,MAAUC,MAAmB,IAA8B;EACrE,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAC1D,IAAIK,MAAM;EACV;AACJ;AACA;AACA;EACI,IAAI,CAACH,QAAQ,EAAE;IACXG,MAAM,GAAG,MAAMJ,MAAM,CAACF,KAAK,CAACI,YAAY,EAAEC,OAAO,CAAC;EACtD,CAAC,MAAM,IAAI,OAAOF,QAAQ,CAACI,IAAI,KAAK,UAAU,EAAE;IAC5C;AACR;AACA;AACA;AACA;IACQD,MAAM,GAAG,MAAMH,QAAQ,CAACI,IAAI,EAAE;IAC9B,IAAID,MAAM,KAAK,KAAK,EAAE;MAClB,OAAO;QACHA,MAAM,EAAE,IAAI;QACZE,KAAK,EAAE;MACX,CAAC;IACL;EACJ,CAAC,MAAM;IACH;AACR;AACA;AACA;AACA;IACQ,OAAO;MACHF,MAAM,EAAE,IAAI;MACZE,KAAK,EAAE;IACX,CAAC;EACL;EACA;AACJ;AACA;EACI,IAAI,CAACF,MAAM,IAAI,CAACA,MAAM,CAACG,KAAK,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,MAAM,CAACG,KAAK,CAAC,EAAE;IAC1D,MAAM,IAAIG,cAAW,CACjB,sDAAsD,EACtD,aAAa,EACb;MACIR,YAAY;MACZC;IACJ,CAAC,CACJ;EACL;EACA,OAAO;IACHC,MAAM;IACNE,KAAK,EAAEF,MAAM,CAACG;EAClB,CAAC;AACL,CAAC;AACD;AACA;AACA;AACO,MAAMI,QAAQ,GAAG,MAAUZ,MAAsB,IAAgC;EACpF,MAAM;IAAEO;EAAM,CAAC,GAAG,MAAMR,KAAK,6DACtBC,MAAM;IACTI,OAAO,8DACCJ,MAAM,CAACI,OAAO,IAAI,CAAC,CAAC;MACxBS,KAAK,EAAE;IAAC;EACX,GACH;EACF,MAAMC,IAAI,GAAGP,KAAK,CAACQ,KAAK,EAAE;EAC1B,OAAOD,IAAI,GAAGA,IAAI,GAAG,IAAI;AAC7B,CAAC;AACD;AACA;AACA;AAFA;AAGO,MAAME,QAAQ,GAAG,MAAUhB,MAAsB,IAA2B;EAC/E,MAAMO,KAAkB,GAAG,EAAE;EAC7B,IAAIU,OAA+B;EACnC,IAAIC,cAAmB,GAAGC,SAAS;EACnC,OAAQF,OAAO,GAAG,MAAMlB,KAAK,6DAAMC,MAAM;IAAEE,QAAQ,EAAEgB;EAAc,GAAG,EAAG;IACrEX,KAAK,CAACa,IAAI,CAAC,GAAGH,OAAO,CAACV,KAAK,CAAC;IAC5B,IAAI,CAACU,OAAO,CAACZ,MAAM,EAAE;MACjB,OAAOE,KAAK;IAChB;IACAW,cAAc,GAAGD,OAAO,CAACZ,MAAM;EACnC;EACA,OAAOE,KAAK;AAChB,CAAC;;AAED;AACA;AACA;AACA;AAHA;AAIO,MAAMc,oBAAoB,GAAG,OAChCrB,MAAsB,EACtBsB,QAA+C,KAC/B;EAChB,IAAIL,OAA+B;EACnC,IAAIC,cAAmB,GAAGC,SAAS;EACnC,OAAQF,OAAO,GAAG,MAAMlB,KAAK,6DAAMC,MAAM;IAAEE,QAAQ,EAAEgB;EAAc,GAAG,EAAG;IACrE,IAAI,CAACD,OAAO,CAACZ,MAAM,EAAE;MACjB;IACJ;IACA,MAAMiB,QAAQ,CAACL,OAAO,CAACV,KAAK,CAAC;IAC7BW,cAAc,GAAGD,OAAO,CAACZ,MAAM;EACnC;AACJ,CAAC;AAAC"}
|