@declaro/data 2.0.0-beta.62 → 2.0.0-beta.63
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/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +3 -3
- package/dist/node/index.cjs +15 -8
- package/dist/node/index.cjs.map +3 -3
- package/dist/node/index.js +15 -8
- package/dist/node/index.js.map +3 -3
- package/dist/ts/domain/interfaces/repository.d.ts +7 -0
- package/dist/ts/domain/interfaces/repository.d.ts.map +1 -1
- package/dist/ts/test/mock/repositories/mock-memory-repository.d.ts +7 -0
- package/dist/ts/test/mock/repositories/mock-memory-repository.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/domain/interfaces/repository.ts +8 -0
- package/src/test/mock/repositories/mock-memory-repository.test.ts +87 -0
- package/src/test/mock/repositories/mock-memory-repository.ts +22 -8
package/dist/node/index.cjs
CHANGED
|
@@ -121495,13 +121495,7 @@ class MockMemoryRepository {
|
|
|
121495
121495
|
}
|
|
121496
121496
|
async search(input, options) {
|
|
121497
121497
|
const pagination = options?.pagination || { page: 1, pageSize: 25 };
|
|
121498
|
-
let items =
|
|
121499
|
-
if (typeof this.args.filter === "function") {
|
|
121500
|
-
return this.args.filter(item, input);
|
|
121501
|
-
} else {
|
|
121502
|
-
return true;
|
|
121503
|
-
}
|
|
121504
|
-
});
|
|
121498
|
+
let items = this.applyFilters(input);
|
|
121505
121499
|
if (options?.sort && Array.isArray(options.sort)) {
|
|
121506
121500
|
items = items.sort((a, b10) => {
|
|
121507
121501
|
for (const sortField of options.sort) {
|
|
@@ -121592,6 +121586,19 @@ class MockMemoryRepository {
|
|
|
121592
121586
|
this.data.set(primaryKeyValue, updatedItem);
|
|
121593
121587
|
return updatedItem;
|
|
121594
121588
|
}
|
|
121589
|
+
async count(search, options) {
|
|
121590
|
+
const filteredItems = this.applyFilters(search);
|
|
121591
|
+
return filteredItems.length;
|
|
121592
|
+
}
|
|
121593
|
+
applyFilters(input) {
|
|
121594
|
+
return Array.from(this.data.values()).filter((item) => {
|
|
121595
|
+
if (typeof this.args.filter === "function") {
|
|
121596
|
+
return this.args.filter(item, input);
|
|
121597
|
+
} else {
|
|
121598
|
+
return true;
|
|
121599
|
+
}
|
|
121600
|
+
});
|
|
121601
|
+
}
|
|
121595
121602
|
async generatePrimaryKey() {
|
|
121596
121603
|
const lookupModel = this.args.schema.definition.lookup;
|
|
121597
121604
|
const lookupMeta = await lookupModel.toJSONSchema();
|
|
@@ -121607,5 +121614,5 @@ class MockMemoryRepository {
|
|
|
121607
121614
|
}
|
|
121608
121615
|
}
|
|
121609
121616
|
|
|
121610
|
-
//# debugId=
|
|
121617
|
+
//# debugId=7897827112435D4B64756E2164756E21
|
|
121611
121618
|
//# sourceMappingURL=index.cjs.map
|