@sprucelabs/data-stores 26.2.8 → 26.3.0
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/.spruce/errors/dataStores/queryNotFaked.schema.d.ts +3 -0
- package/build/.spruce/errors/dataStores/queryNotFaked.schema.js +23 -0
- package/build/.spruce/errors/errors.types.d.ts +27 -0
- package/build/.spruce/errors/options.types.d.ts +4 -1
- package/build/databases/MongoDatabase.js +1 -0
- package/build/databases/NeDbDatabase.d.ts +4 -1
- package/build/databases/NeDbDatabase.js +11 -2
- package/build/errors/SpruceError.js +3 -0
- package/build/errors/queryNotFaked.builder.d.ts +17 -0
- package/build/errors/queryNotFaked.builder.js +17 -0
- package/build/esm/.spruce/errors/errors.types.d.ts +27 -0
- package/build/esm/.spruce/errors/options.types.d.ts +4 -1
- package/build/esm/databases/MongoDatabase.js +1 -0
- package/build/esm/databases/NeDbDatabase.d.ts +4 -1
- package/build/esm/databases/NeDbDatabase.js +11 -2
- package/build/esm/errors/SpruceError.js +3 -0
- package/build/esm/errors/queryNotFaked.builder.d.ts +17 -0
- package/build/esm/errors/queryNotFaked.builder.js +15 -0
- package/build/esm/stores/AbstractStore.js +6 -3
- package/build/esm/types/database.types.d.ts +1 -1
- package/build/stores/AbstractStore.js +6 -3
- package/build/types/database.types.d.ts +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
4
|
+
const queryNotFakedSchema = {
|
|
5
|
+
id: 'queryNotFaked',
|
|
6
|
+
namespace: 'DataStores',
|
|
7
|
+
name: 'Query not faked',
|
|
8
|
+
fields: {
|
|
9
|
+
/** . */
|
|
10
|
+
'query': {
|
|
11
|
+
type: 'text',
|
|
12
|
+
isRequired: true,
|
|
13
|
+
options: undefined
|
|
14
|
+
},
|
|
15
|
+
/** . */
|
|
16
|
+
'params': {
|
|
17
|
+
type: 'raw',
|
|
18
|
+
options: { valueType: `Record<string, any>`, }
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
schema_1.SchemaRegistry.getInstance().trackSchema(queryNotFakedSchema);
|
|
23
|
+
exports.default = queryNotFakedSchema;
|
|
@@ -134,6 +134,33 @@ export declare namespace SpruceErrors.DataStores {
|
|
|
134
134
|
}
|
|
135
135
|
type RecordNotFoundEntity = SchemaEntity<SpruceErrors.DataStores.RecordNotFoundSchema>;
|
|
136
136
|
}
|
|
137
|
+
export declare namespace SpruceErrors.DataStores {
|
|
138
|
+
interface QueryNotFaked {
|
|
139
|
+
'query': string;
|
|
140
|
+
'params'?: (Record<string, any>) | undefined | null;
|
|
141
|
+
}
|
|
142
|
+
interface QueryNotFakedSchema extends SpruceSchema.Schema {
|
|
143
|
+
id: 'queryNotFaked';
|
|
144
|
+
namespace: 'DataStores';
|
|
145
|
+
name: 'Query not faked';
|
|
146
|
+
fields: {
|
|
147
|
+
/** . */
|
|
148
|
+
'query': {
|
|
149
|
+
type: 'text';
|
|
150
|
+
isRequired: true;
|
|
151
|
+
options: undefined;
|
|
152
|
+
};
|
|
153
|
+
/** . */
|
|
154
|
+
'params': {
|
|
155
|
+
type: 'raw';
|
|
156
|
+
options: {
|
|
157
|
+
valueType: `Record<string, any>`;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
type QueryNotFakedEntity = SchemaEntity<SpruceErrors.DataStores.QueryNotFakedSchema>;
|
|
163
|
+
}
|
|
137
164
|
export declare namespace SpruceErrors.DataStores {
|
|
138
165
|
interface NotImplemented {
|
|
139
166
|
}
|
|
@@ -18,6 +18,9 @@ export interface ScrambleNotConfiguredErrorOptions extends SpruceErrors.DataStor
|
|
|
18
18
|
export interface RecordNotFoundErrorOptions extends SpruceErrors.DataStores.RecordNotFound, ISpruceErrorOptions {
|
|
19
19
|
code: 'RECORD_NOT_FOUND';
|
|
20
20
|
}
|
|
21
|
+
export interface QueryNotFakedErrorOptions extends SpruceErrors.DataStores.QueryNotFaked, ISpruceErrorOptions {
|
|
22
|
+
code: 'QUERY_NOT_FAKED';
|
|
23
|
+
}
|
|
21
24
|
export interface NotImplementedErrorOptions extends SpruceErrors.DataStores.NotImplemented, ISpruceErrorOptions {
|
|
22
25
|
code: 'NOT_IMPLEMENTED';
|
|
23
26
|
}
|
|
@@ -60,5 +63,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
|
|
|
60
63
|
export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
|
|
61
64
|
code: 'DATABASE_NOT_CONNECTED';
|
|
62
65
|
}
|
|
63
|
-
type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
|
|
66
|
+
type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | QueryNotFakedErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
|
|
64
67
|
export default ErrorOptions;
|
|
@@ -4,6 +4,7 @@ import { QueryOptions } from '../types/query.types';
|
|
|
4
4
|
export default class NeDbDatabase extends AbstractMutexer implements Database {
|
|
5
5
|
private collections;
|
|
6
6
|
private _isConnected;
|
|
7
|
+
private fakedQueries;
|
|
7
8
|
generateId(): string;
|
|
8
9
|
connect(): Promise<void>;
|
|
9
10
|
close(): Promise<void>;
|
|
@@ -39,5 +40,7 @@ export default class NeDbDatabase extends AbstractMutexer implements Database {
|
|
|
39
40
|
createIndex(collection: string, fields: string[]): Promise<void>;
|
|
40
41
|
syncUniqueIndexes(collectionName: string, indexes: string[][]): Promise<void>;
|
|
41
42
|
syncIndexes(collectionName: string, indexes: string[][]): Promise<void>;
|
|
42
|
-
query<T>(): Promise<T>;
|
|
43
|
+
query<T>(query: string, params?: Record<string, any>): Promise<T>;
|
|
44
|
+
fakeQuery<T>(query: string, cb: FakeQueryHandler<T>): void;
|
|
43
45
|
}
|
|
46
|
+
export type FakeQueryHandler<T> = (params?: Record<string, any>) => Promise<T> | T;
|
|
@@ -36,6 +36,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
36
36
|
super(...arguments);
|
|
37
37
|
this.collections = {};
|
|
38
38
|
this._isConnected = false;
|
|
39
|
+
this.fakedQueries = {};
|
|
39
40
|
}
|
|
40
41
|
generateId() {
|
|
41
42
|
return (0, generateId_1.default)();
|
|
@@ -458,10 +459,18 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
458
459
|
await this.dropIndex(collectionName, extra);
|
|
459
460
|
}
|
|
460
461
|
}
|
|
461
|
-
async query() {
|
|
462
|
+
async query(query, params) {
|
|
463
|
+
const cb = this.fakedQueries[query];
|
|
464
|
+
if (cb) {
|
|
465
|
+
return cb(params);
|
|
466
|
+
}
|
|
462
467
|
throw new SpruceError_1.default({
|
|
463
|
-
code: '
|
|
468
|
+
code: 'QUERY_NOT_FAKED',
|
|
469
|
+
query,
|
|
464
470
|
});
|
|
465
471
|
}
|
|
472
|
+
fakeQuery(query, cb) {
|
|
473
|
+
this.fakedQueries[query] = cb;
|
|
474
|
+
}
|
|
466
475
|
}
|
|
467
476
|
exports.default = NeDbDatabase;
|
|
@@ -102,6 +102,9 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
|
|
|
102
102
|
case 'NOT_IMPLEMENTED':
|
|
103
103
|
message = 'A Not implemented just happened!';
|
|
104
104
|
break;
|
|
105
|
+
case 'QUERY_NOT_FAKED':
|
|
106
|
+
message = `The query '${options.query}' was not faked. Try this.stores.fakeQuery(...).`;
|
|
107
|
+
break;
|
|
105
108
|
default:
|
|
106
109
|
message = super.friendlyMessage();
|
|
107
110
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
4
|
+
exports.default = (0, schema_1.buildErrorSchema)({
|
|
5
|
+
id: 'queryNotFaked',
|
|
6
|
+
name: 'Query not faked',
|
|
7
|
+
fields: {
|
|
8
|
+
query: {
|
|
9
|
+
type: 'text',
|
|
10
|
+
isRequired: true,
|
|
11
|
+
},
|
|
12
|
+
params: {
|
|
13
|
+
type: 'raw',
|
|
14
|
+
options: { valueType: 'Record<string, any>' },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -134,6 +134,33 @@ export declare namespace SpruceErrors.DataStores {
|
|
|
134
134
|
}
|
|
135
135
|
type RecordNotFoundEntity = SchemaEntity<SpruceErrors.DataStores.RecordNotFoundSchema>;
|
|
136
136
|
}
|
|
137
|
+
export declare namespace SpruceErrors.DataStores {
|
|
138
|
+
interface QueryNotFaked {
|
|
139
|
+
'query': string;
|
|
140
|
+
'params'?: (Record<string, any>) | undefined | null;
|
|
141
|
+
}
|
|
142
|
+
interface QueryNotFakedSchema extends SpruceSchema.Schema {
|
|
143
|
+
id: 'queryNotFaked';
|
|
144
|
+
namespace: 'DataStores';
|
|
145
|
+
name: 'Query not faked';
|
|
146
|
+
fields: {
|
|
147
|
+
/** . */
|
|
148
|
+
'query': {
|
|
149
|
+
type: 'text';
|
|
150
|
+
isRequired: true;
|
|
151
|
+
options: undefined;
|
|
152
|
+
};
|
|
153
|
+
/** . */
|
|
154
|
+
'params': {
|
|
155
|
+
type: 'raw';
|
|
156
|
+
options: {
|
|
157
|
+
valueType: `Record<string, any>`;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
type QueryNotFakedEntity = SchemaEntity<SpruceErrors.DataStores.QueryNotFakedSchema>;
|
|
163
|
+
}
|
|
137
164
|
export declare namespace SpruceErrors.DataStores {
|
|
138
165
|
interface NotImplemented {
|
|
139
166
|
}
|
|
@@ -18,6 +18,9 @@ export interface ScrambleNotConfiguredErrorOptions extends SpruceErrors.DataStor
|
|
|
18
18
|
export interface RecordNotFoundErrorOptions extends SpruceErrors.DataStores.RecordNotFound, ISpruceErrorOptions {
|
|
19
19
|
code: 'RECORD_NOT_FOUND';
|
|
20
20
|
}
|
|
21
|
+
export interface QueryNotFakedErrorOptions extends SpruceErrors.DataStores.QueryNotFaked, ISpruceErrorOptions {
|
|
22
|
+
code: 'QUERY_NOT_FAKED';
|
|
23
|
+
}
|
|
21
24
|
export interface NotImplementedErrorOptions extends SpruceErrors.DataStores.NotImplemented, ISpruceErrorOptions {
|
|
22
25
|
code: 'NOT_IMPLEMENTED';
|
|
23
26
|
}
|
|
@@ -60,5 +63,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
|
|
|
60
63
|
export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
|
|
61
64
|
code: 'DATABASE_NOT_CONNECTED';
|
|
62
65
|
}
|
|
63
|
-
type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
|
|
66
|
+
type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | QueryNotFakedErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
|
|
64
67
|
export default ErrorOptions;
|
|
@@ -490,6 +490,7 @@ export default class MongoDatabase {
|
|
|
490
490
|
return __awaiter(this, void 0, void 0, function* () {
|
|
491
491
|
throw new SpruceError({
|
|
492
492
|
code: 'NOT_IMPLEMENTED',
|
|
493
|
+
friendlyMessage: `You cannot run a query using mongodb. Try a different database adapter!`,
|
|
493
494
|
});
|
|
494
495
|
});
|
|
495
496
|
}
|
|
@@ -4,6 +4,7 @@ import { QueryOptions } from '../types/query.types';
|
|
|
4
4
|
export default class NeDbDatabase extends AbstractMutexer implements Database {
|
|
5
5
|
private collections;
|
|
6
6
|
private _isConnected;
|
|
7
|
+
private fakedQueries;
|
|
7
8
|
generateId(): string;
|
|
8
9
|
connect(): Promise<void>;
|
|
9
10
|
close(): Promise<void>;
|
|
@@ -39,5 +40,7 @@ export default class NeDbDatabase extends AbstractMutexer implements Database {
|
|
|
39
40
|
createIndex(collection: string, fields: string[]): Promise<void>;
|
|
40
41
|
syncUniqueIndexes(collectionName: string, indexes: string[][]): Promise<void>;
|
|
41
42
|
syncIndexes(collectionName: string, indexes: string[][]): Promise<void>;
|
|
42
|
-
query<T>(): Promise<T>;
|
|
43
|
+
query<T>(query: string, params?: Record<string, any>): Promise<T>;
|
|
44
|
+
fakeQuery<T>(query: string, cb: FakeQueryHandler<T>): void;
|
|
43
45
|
}
|
|
46
|
+
export type FakeQueryHandler<T> = (params?: Record<string, any>) => Promise<T> | T;
|
|
@@ -40,6 +40,7 @@ export default class NeDbDatabase extends AbstractMutexer {
|
|
|
40
40
|
super(...arguments);
|
|
41
41
|
this.collections = {};
|
|
42
42
|
this._isConnected = false;
|
|
43
|
+
this.fakedQueries = {};
|
|
43
44
|
}
|
|
44
45
|
generateId() {
|
|
45
46
|
return generateId();
|
|
@@ -508,11 +509,19 @@ export default class NeDbDatabase extends AbstractMutexer {
|
|
|
508
509
|
}
|
|
509
510
|
});
|
|
510
511
|
}
|
|
511
|
-
query() {
|
|
512
|
+
query(query, params) {
|
|
512
513
|
return __awaiter(this, void 0, void 0, function* () {
|
|
514
|
+
const cb = this.fakedQueries[query];
|
|
515
|
+
if (cb) {
|
|
516
|
+
return cb(params);
|
|
517
|
+
}
|
|
513
518
|
throw new SpruceError({
|
|
514
|
-
code: '
|
|
519
|
+
code: 'QUERY_NOT_FAKED',
|
|
520
|
+
query,
|
|
515
521
|
});
|
|
516
522
|
});
|
|
517
523
|
}
|
|
524
|
+
fakeQuery(query, cb) {
|
|
525
|
+
this.fakedQueries[query] = cb;
|
|
526
|
+
}
|
|
518
527
|
}
|
|
@@ -97,6 +97,9 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
|
|
|
97
97
|
case 'NOT_IMPLEMENTED':
|
|
98
98
|
message = 'A Not implemented just happened!';
|
|
99
99
|
break;
|
|
100
|
+
case 'QUERY_NOT_FAKED':
|
|
101
|
+
message = `The query '${options.query}' was not faked. Try this.stores.fakeQuery(...).`;
|
|
102
|
+
break;
|
|
100
103
|
default:
|
|
101
104
|
message = super.friendlyMessage();
|
|
102
105
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { buildErrorSchema } from '@sprucelabs/schema';
|
|
2
|
+
export default buildErrorSchema({
|
|
3
|
+
id: 'queryNotFaked',
|
|
4
|
+
name: 'Query not faked',
|
|
5
|
+
fields: {
|
|
6
|
+
query: {
|
|
7
|
+
type: 'text',
|
|
8
|
+
isRequired: true,
|
|
9
|
+
},
|
|
10
|
+
params: {
|
|
11
|
+
type: 'raw',
|
|
12
|
+
options: { valueType: 'Record<string, any>' },
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -46,7 +46,7 @@ export default class AbstractStore extends AbstractMutexer {
|
|
|
46
46
|
return this.collectionName;
|
|
47
47
|
}
|
|
48
48
|
prepareAndNormalizeRecord(record, options = {}) {
|
|
49
|
-
var _a, _b;
|
|
49
|
+
var _a, _b, _c;
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
let preparedRecord = this.prepareRecord
|
|
52
52
|
? yield this.prepareRecord(record, options)
|
|
@@ -62,7 +62,7 @@ export default class AbstractStore extends AbstractMutexer {
|
|
|
62
62
|
if (this.shouldMapLowerCaseToCamelCase) {
|
|
63
63
|
this.mapCasing(preparedRecord);
|
|
64
64
|
}
|
|
65
|
-
return normalizeSchemaValues(this.fullSchema, preparedRecord, Object.assign(Object.assign({}, options), { fields: options.includeFields, shouldIncludePrivateFields: options.shouldIncludePrivateFields === true, shouldCreateEntityInstances: false, shouldIncludeNullAndUndefinedFields:
|
|
65
|
+
return normalizeSchemaValues(this.fullSchema, preparedRecord, Object.assign(Object.assign({}, options), { fields: options.includeFields, shouldIncludePrivateFields: options.shouldIncludePrivateFields === true, shouldCreateEntityInstances: false, shouldIncludeNullAndUndefinedFields: !((_c = options.shouldStripUndefinedAndNullValues) !== null && _c !== void 0 ? _c : true) }));
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
mapCasing(preparedRecord) {
|
|
@@ -241,7 +241,10 @@ export default class AbstractStore extends AbstractMutexer {
|
|
|
241
241
|
primaryFieldNames: this.primaryFieldNames,
|
|
242
242
|
});
|
|
243
243
|
if (results) {
|
|
244
|
-
const all = results.map((result) =>
|
|
244
|
+
const all = results.map((result) => {
|
|
245
|
+
var _a;
|
|
246
|
+
return this.prepareAndNormalizeRecord(result, Object.assign(Object.assign({}, options), { shouldStripUndefinedAndNullValues: (_a = options === null || options === void 0 ? void 0 : options.shouldStripUndefinedAndNullValues) !== null && _a !== void 0 ? _a : true }));
|
|
247
|
+
});
|
|
245
248
|
const records = yield Promise.all(all);
|
|
246
249
|
return records;
|
|
247
250
|
}
|
|
@@ -26,7 +26,7 @@ export interface Database {
|
|
|
26
26
|
count(collection: string, query?: Record<string, any>): Promise<number>;
|
|
27
27
|
createUniqueIndex(collection: string, fields: UniqueIndex): Promise<void>;
|
|
28
28
|
createIndex(collection: string, fields: Index): Promise<void>;
|
|
29
|
-
query<T>(query: string): Promise<T>;
|
|
29
|
+
query<T>(query: string, params?: Record<string, any>): Promise<T>;
|
|
30
30
|
}
|
|
31
31
|
export interface DatabaseOptions {
|
|
32
32
|
dbName?: string;
|
|
@@ -65,7 +65,7 @@ class AbstractStore extends AbstractMutexer_1.default {
|
|
|
65
65
|
return this.collectionName;
|
|
66
66
|
}
|
|
67
67
|
async prepareAndNormalizeRecord(record, options = {}) {
|
|
68
|
-
var _a, _b;
|
|
68
|
+
var _a, _b, _c;
|
|
69
69
|
let preparedRecord = this.prepareRecord
|
|
70
70
|
? await this.prepareRecord(record, options)
|
|
71
71
|
: record;
|
|
@@ -80,7 +80,7 @@ class AbstractStore extends AbstractMutexer_1.default {
|
|
|
80
80
|
if (this.shouldMapLowerCaseToCamelCase) {
|
|
81
81
|
this.mapCasing(preparedRecord);
|
|
82
82
|
}
|
|
83
|
-
return (0, schema_1.normalizeSchemaValues)(this.fullSchema, preparedRecord, Object.assign(Object.assign({}, options), { fields: options.includeFields, shouldIncludePrivateFields: options.shouldIncludePrivateFields === true, shouldCreateEntityInstances: false, shouldIncludeNullAndUndefinedFields:
|
|
83
|
+
return (0, schema_1.normalizeSchemaValues)(this.fullSchema, preparedRecord, Object.assign(Object.assign({}, options), { fields: options.includeFields, shouldIncludePrivateFields: options.shouldIncludePrivateFields === true, shouldCreateEntityInstances: false, shouldIncludeNullAndUndefinedFields: !((_c = options.shouldStripUndefinedAndNullValues) !== null && _c !== void 0 ? _c : true) }));
|
|
84
84
|
}
|
|
85
85
|
mapCasing(preparedRecord) {
|
|
86
86
|
var _a;
|
|
@@ -239,7 +239,10 @@ class AbstractStore extends AbstractMutexer_1.default {
|
|
|
239
239
|
primaryFieldNames: this.primaryFieldNames,
|
|
240
240
|
});
|
|
241
241
|
if (results) {
|
|
242
|
-
const all = results.map((result) =>
|
|
242
|
+
const all = results.map((result) => {
|
|
243
|
+
var _a;
|
|
244
|
+
return this.prepareAndNormalizeRecord(result, Object.assign(Object.assign({}, options), { shouldStripUndefinedAndNullValues: (_a = options === null || options === void 0 ? void 0 : options.shouldStripUndefinedAndNullValues) !== null && _a !== void 0 ? _a : true }));
|
|
245
|
+
});
|
|
243
246
|
const records = await Promise.all(all);
|
|
244
247
|
return records;
|
|
245
248
|
}
|
|
@@ -26,7 +26,7 @@ export interface Database {
|
|
|
26
26
|
count(collection: string, query?: Record<string, any>): Promise<number>;
|
|
27
27
|
createUniqueIndex(collection: string, fields: UniqueIndex): Promise<void>;
|
|
28
28
|
createIndex(collection: string, fields: Index): Promise<void>;
|
|
29
|
-
query<T>(query: string): Promise<T>;
|
|
29
|
+
query<T>(query: string, params?: Record<string, any>): Promise<T>;
|
|
30
30
|
}
|
|
31
31
|
export interface DatabaseOptions {
|
|
32
32
|
dbName?: string;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "26.
|
|
6
|
+
"version": "26.3.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"build/**/*",
|
|
9
9
|
"!build/__tests__",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"upgrade.packages.test": "yarn upgrade.packages.all && yarn lint && yarn build.dev && yarn test"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@sprucelabs/error": "^5.1.
|
|
71
|
+
"@sprucelabs/error": "^5.1.53",
|
|
72
72
|
"@sprucelabs/globby": "^1.0.3",
|
|
73
73
|
"@sprucelabs/schema": "^29.3.0",
|
|
74
74
|
"@sprucelabs/spruce-skill-utils": "^30.1.44",
|
|
@@ -78,10 +78,10 @@
|
|
|
78
78
|
"nedb": "^1.8.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@sprucelabs/esm-postbuild": "^5.0.
|
|
82
|
-
"@sprucelabs/jest-json-reporter": "^7.0.
|
|
81
|
+
"@sprucelabs/esm-postbuild": "^5.0.109",
|
|
82
|
+
"@sprucelabs/jest-json-reporter": "^7.0.134",
|
|
83
83
|
"@sprucelabs/jest-sheets-reporter": "^3.0.26",
|
|
84
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
84
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.271",
|
|
85
85
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
86
86
|
"@sprucelabs/test": "^8.0.35",
|
|
87
87
|
"@sprucelabs/test-utils": "^4.0.86",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"eslint-config-spruce": "^10.13.6",
|
|
96
96
|
"jest": "^29.7.0",
|
|
97
97
|
"jest-circus": "^29.7.0",
|
|
98
|
-
"prettier": "^3.1.
|
|
98
|
+
"prettier": "^3.1.1",
|
|
99
99
|
"ts-node": "^10.9.2",
|
|
100
100
|
"tsc-watch": "^6.0.4",
|
|
101
101
|
"tsconfig-paths": "^4.2.0",
|