@sprucelabs/data-stores 25.3.2 → 25.4.1
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/build/cursors/BatchCursor.d.ts +2 -2
- package/build/cursors/BatchCursor.js +4 -5
- package/build/esm/cursors/BatchCursor.d.ts +2 -2
- package/build/esm/cursors/BatchCursor.js +4 -5
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/stores/AbstractStore.d.ts +2 -2
- package/build/esm/tests/databaseAssertUtil.d.ts +2 -2
- package/build/index.d.ts +1 -1
- package/build/index.js +2 -2
- package/build/stores/AbstractStore.d.ts +2 -2
- package/build/tests/databaseAssertUtil.d.ts +2 -2
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export default class BatchCursorImpl<ResponseRecord> implements BatchCursor<Resp
|
|
|
6
6
|
private store;
|
|
7
7
|
private options?;
|
|
8
8
|
private query?;
|
|
9
|
-
private
|
|
9
|
+
private nextHandler?;
|
|
10
10
|
private constructor();
|
|
11
11
|
static Cursor<Response>(store: AbstractStore<Schema>, query?: Record<string, any>, options?: FindBatchOptions): BatchCursor<Response>;
|
|
12
12
|
setOnNextResults(cb: (results: ResponseRecord[]) => never[]): void;
|
|
@@ -17,6 +17,6 @@ export interface FindBatchOptions<IncludePrivateFields extends boolean = true, F
|
|
|
17
17
|
batchSize?: number;
|
|
18
18
|
}
|
|
19
19
|
export interface BatchCursor<ResponseRecord> {
|
|
20
|
-
setOnNextResults(cb: (results: ResponseRecord[]) =>
|
|
20
|
+
setOnNextResults(cb: (results: ResponseRecord[]) => Record<string, any>[]): void;
|
|
21
21
|
next(): Promise<ResponseRecord[] | null>;
|
|
22
22
|
}
|
|
@@ -21,15 +21,11 @@ class BatchCursorImpl {
|
|
|
21
21
|
return new this(store, query, options);
|
|
22
22
|
}
|
|
23
23
|
setOnNextResults(cb) {
|
|
24
|
-
this.
|
|
24
|
+
this.nextHandler = cb;
|
|
25
25
|
}
|
|
26
26
|
async next() {
|
|
27
27
|
var _a;
|
|
28
28
|
const _b = (_a = this.options) !== null && _a !== void 0 ? _a : {}, { batchSize = 10 } = _b, rest = __rest(_b, ["batchSize"]);
|
|
29
|
-
if (this.nextResults) {
|
|
30
|
-
//@ts-ignore
|
|
31
|
-
return this.nextResults();
|
|
32
|
-
}
|
|
33
29
|
const matches = await this.store.find(Object.assign({}, this.query), {
|
|
34
30
|
limit: batchSize,
|
|
35
31
|
}, Object.assign({}, rest));
|
|
@@ -37,6 +33,9 @@ class BatchCursorImpl {
|
|
|
37
33
|
return null;
|
|
38
34
|
}
|
|
39
35
|
this.bumpCursorPosition(matches);
|
|
36
|
+
if (this.nextHandler) {
|
|
37
|
+
return this.nextHandler(matches);
|
|
38
|
+
}
|
|
40
39
|
return matches;
|
|
41
40
|
}
|
|
42
41
|
bumpCursorPosition(matches) {
|
|
@@ -6,7 +6,7 @@ export default class BatchCursorImpl<ResponseRecord> implements BatchCursor<Resp
|
|
|
6
6
|
private store;
|
|
7
7
|
private options?;
|
|
8
8
|
private query?;
|
|
9
|
-
private
|
|
9
|
+
private nextHandler?;
|
|
10
10
|
private constructor();
|
|
11
11
|
static Cursor<Response>(store: AbstractStore<Schema>, query?: Record<string, any>, options?: FindBatchOptions): BatchCursor<Response>;
|
|
12
12
|
setOnNextResults(cb: (results: ResponseRecord[]) => never[]): void;
|
|
@@ -17,6 +17,6 @@ export interface FindBatchOptions<IncludePrivateFields extends boolean = true, F
|
|
|
17
17
|
batchSize?: number;
|
|
18
18
|
}
|
|
19
19
|
export interface BatchCursor<ResponseRecord> {
|
|
20
|
-
setOnNextResults(cb: (results: ResponseRecord[]) =>
|
|
20
|
+
setOnNextResults(cb: (results: ResponseRecord[]) => Record<string, any>[]): void;
|
|
21
21
|
next(): Promise<ResponseRecord[] | null>;
|
|
22
22
|
}
|
|
@@ -28,16 +28,12 @@ export default class BatchCursorImpl {
|
|
|
28
28
|
return new this(store, query, options);
|
|
29
29
|
}
|
|
30
30
|
setOnNextResults(cb) {
|
|
31
|
-
this.
|
|
31
|
+
this.nextHandler = cb;
|
|
32
32
|
}
|
|
33
33
|
next() {
|
|
34
34
|
var _a;
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
36
|
const _b = (_a = this.options) !== null && _a !== void 0 ? _a : {}, { batchSize = 10 } = _b, rest = __rest(_b, ["batchSize"]);
|
|
37
|
-
if (this.nextResults) {
|
|
38
|
-
//@ts-ignore
|
|
39
|
-
return this.nextResults();
|
|
40
|
-
}
|
|
41
37
|
const matches = yield this.store.find(Object.assign({}, this.query), {
|
|
42
38
|
limit: batchSize,
|
|
43
39
|
}, Object.assign({}, rest));
|
|
@@ -45,6 +41,9 @@ export default class BatchCursorImpl {
|
|
|
45
41
|
return null;
|
|
46
42
|
}
|
|
47
43
|
this.bumpCursorPosition(matches);
|
|
44
|
+
if (this.nextHandler) {
|
|
45
|
+
return this.nextHandler(matches);
|
|
46
|
+
}
|
|
48
47
|
return matches;
|
|
49
48
|
});
|
|
50
49
|
}
|
package/build/esm/index.d.ts
CHANGED
|
@@ -25,5 +25,5 @@ export * from './cursors/CursorPager';
|
|
|
25
25
|
*/
|
|
26
26
|
export { default as databaseAssertUtil } from './tests/databaseAssertUtil';
|
|
27
27
|
export { default as databaseAssert } from './tests/databaseAssertUtil';
|
|
28
|
-
export { default as
|
|
28
|
+
export { default as BatchCursorImpl } from './cursors/BatchCursor';
|
|
29
29
|
export * from './cursors/BatchCursor';
|
package/build/esm/index.js
CHANGED
|
@@ -25,5 +25,5 @@ export * from './cursors/CursorPager.js';
|
|
|
25
25
|
*/
|
|
26
26
|
export { default as databaseAssertUtil } from './tests/databaseAssertUtil.js';
|
|
27
27
|
export { default as databaseAssert } from './tests/databaseAssertUtil.js';
|
|
28
|
-
export { default as
|
|
28
|
+
export { default as BatchCursorImpl } from './cursors/BatchCursor.js';
|
|
29
29
|
export * from './cursors/BatchCursor.js';
|
|
@@ -3,10 +3,10 @@ import { FindBatchOptions } from '../cursors/BatchCursor';
|
|
|
3
3
|
import AbstractMutexer from '../mutexers/AbstractMutexer';
|
|
4
4
|
import { Database } from '../types/database.types';
|
|
5
5
|
import { QueryBuilder, QueryOptions } from '../types/query.types';
|
|
6
|
-
import { PrepareOptions, PrepareResults, SaveOperations } from '../types/stores.types';
|
|
6
|
+
import { PrepareOptions, PrepareResults, SaveOperations, Store } from '../types/stores.types';
|
|
7
7
|
export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema> & {
|
|
8
8
|
id: string;
|
|
9
|
-
}, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer {
|
|
9
|
+
}, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer implements Store {
|
|
10
10
|
abstract readonly name: string;
|
|
11
11
|
protected abstract collectionName: string;
|
|
12
12
|
protected abstract createSchema: CreateSchema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import AbstractStore from '../stores/AbstractStore';
|
|
2
1
|
import { Database, Index, TestConnect, UniqueIndex } from '../types/database.types';
|
|
2
|
+
import { Store } from '../types/stores.types';
|
|
3
3
|
declare const databaseAssertUtil: {
|
|
4
4
|
collectionName: string;
|
|
5
5
|
runSuite(connect: TestConnect, tests?: string[]): Promise<void>;
|
|
@@ -79,6 +79,6 @@ declare const databaseAssertUtil: {
|
|
|
79
79
|
_assertThrowsExpectedNotFoundOnUpdateOne(db: Database, query: Record<string, any>): Promise<void>;
|
|
80
80
|
_assert$orReturnsExpectedTotalRecords(db: Database, $or: Record<string, any>[], expected: number): Promise<void>;
|
|
81
81
|
_assertCanCreateMultiFieldIndex(connect: TestConnect, fields: string[]): Promise<void>;
|
|
82
|
-
assertHasLowerCaseToCamelCaseMappingEnabled(store:
|
|
82
|
+
assertHasLowerCaseToCamelCaseMappingEnabled(store: Store): void;
|
|
83
83
|
};
|
|
84
84
|
export default databaseAssertUtil;
|
package/build/index.d.ts
CHANGED
|
@@ -25,5 +25,5 @@ export * from './cursors/CursorPager';
|
|
|
25
25
|
*/
|
|
26
26
|
export { default as databaseAssertUtil } from './tests/databaseAssertUtil';
|
|
27
27
|
export { default as databaseAssert } from './tests/databaseAssertUtil';
|
|
28
|
-
export { default as
|
|
28
|
+
export { default as BatchCursorImpl } from './cursors/BatchCursor';
|
|
29
29
|
export * from './cursors/BatchCursor';
|
package/build/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.BatchCursorImpl = exports.databaseAssert = exports.databaseAssertUtil = exports.CursorPagerFaker = exports.CursorPager = exports.generateId = exports.DataStoresError = exports.mongoUtil = exports.NeDbDatabase = exports.MongoDatabase = exports.StoreLoader = exports.DatabaseFactory = exports.StoreFactory = exports.AbstractStore = exports.DatabaseFixture = exports.AbstractDatabaseTest = void 0;
|
|
21
21
|
var AbstractDatabaseTest_1 = require("./tests/AbstractDatabaseTest");
|
|
22
22
|
Object.defineProperty(exports, "AbstractDatabaseTest", { enumerable: true, get: function () { return __importDefault(AbstractDatabaseTest_1).default; } });
|
|
23
23
|
var DatabaseFixture_1 = require("./fixtures/DatabaseFixture");
|
|
@@ -61,5 +61,5 @@ Object.defineProperty(exports, "databaseAssertUtil", { enumerable: true, get: fu
|
|
|
61
61
|
var databaseAssertUtil_2 = require("./tests/databaseAssertUtil");
|
|
62
62
|
Object.defineProperty(exports, "databaseAssert", { enumerable: true, get: function () { return __importDefault(databaseAssertUtil_2).default; } });
|
|
63
63
|
var BatchCursor_1 = require("./cursors/BatchCursor");
|
|
64
|
-
Object.defineProperty(exports, "
|
|
64
|
+
Object.defineProperty(exports, "BatchCursorImpl", { enumerable: true, get: function () { return __importDefault(BatchCursor_1).default; } });
|
|
65
65
|
__exportStar(require("./cursors/BatchCursor"), exports);
|
|
@@ -3,10 +3,10 @@ import { FindBatchOptions } from '../cursors/BatchCursor';
|
|
|
3
3
|
import AbstractMutexer from '../mutexers/AbstractMutexer';
|
|
4
4
|
import { Database } from '../types/database.types';
|
|
5
5
|
import { QueryBuilder, QueryOptions } from '../types/query.types';
|
|
6
|
-
import { PrepareOptions, PrepareResults, SaveOperations } from '../types/stores.types';
|
|
6
|
+
import { PrepareOptions, PrepareResults, SaveOperations, Store } from '../types/stores.types';
|
|
7
7
|
export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema> & {
|
|
8
8
|
id: string;
|
|
9
|
-
}, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer {
|
|
9
|
+
}, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer implements Store {
|
|
10
10
|
abstract readonly name: string;
|
|
11
11
|
protected abstract collectionName: string;
|
|
12
12
|
protected abstract createSchema: CreateSchema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import AbstractStore from '../stores/AbstractStore';
|
|
2
1
|
import { Database, Index, TestConnect, UniqueIndex } from '../types/database.types';
|
|
2
|
+
import { Store } from '../types/stores.types';
|
|
3
3
|
declare const databaseAssertUtil: {
|
|
4
4
|
collectionName: string;
|
|
5
5
|
runSuite(connect: TestConnect, tests?: string[]): Promise<void>;
|
|
@@ -79,6 +79,6 @@ declare const databaseAssertUtil: {
|
|
|
79
79
|
_assertThrowsExpectedNotFoundOnUpdateOne(db: Database, query: Record<string, any>): Promise<void>;
|
|
80
80
|
_assert$orReturnsExpectedTotalRecords(db: Database, $or: Record<string, any>[], expected: number): Promise<void>;
|
|
81
81
|
_assertCanCreateMultiFieldIndex(connect: TestConnect, fields: string[]): Promise<void>;
|
|
82
|
-
assertHasLowerCaseToCamelCaseMappingEnabled(store:
|
|
82
|
+
assertHasLowerCaseToCamelCaseMappingEnabled(store: Store): void;
|
|
83
83
|
};
|
|
84
84
|
export default databaseAssertUtil;
|