@common-stack/store-mongo
Advanced tools
Comparing version 0.6.1-alpha.4 to 3.0.1-alpha.0
import * as DataLoader from 'dataloader'; | ||
import { IBaseService } from '../interfaces'; | ||
import { DataLoaderOptions, IBaseService, IDataLoader } from '../interfaces'; | ||
export declare class BulkDataLoader<T extends { | ||
id: string; | ||
}> extends DataLoader<string, T> { | ||
}> extends DataLoader<string, T> implements IDataLoader<T> { | ||
private readonly service; | ||
constructor(service: IBaseService<T>); | ||
withOptions: DataLoader<DataLoaderOptions<T>, T[], DataLoaderOptions<T>>; | ||
} |
@@ -21,2 +21,13 @@ /******/ (() => { // webpackBootstrap | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
@@ -32,2 +43,9 @@ exports.BulkDataLoader = void 0; | ||
}); | ||
this.service = service; | ||
this.withOptions = new DataLoader(async (options) => { | ||
const [_a] = options, { id, searchKey } = _a, rest = __rest(_a, ["id", "searchKey"]); | ||
const ids = options.map((option) => option.id); | ||
const vehicleModelVariants = await this.service.getAll(Object.assign(Object.assign({}, rest), { criteria: Object.assign(Object.assign({}, rest.criteria), { [searchKey]: { $in: ids } }) })); | ||
return ids.map((modelId) => vehicleModelVariants.filter((i) => i[searchKey].toString() === modelId.toString())); | ||
}); | ||
} | ||
@@ -34,0 +52,0 @@ }; |
import * as DataLoader from 'dataloader'; | ||
export type IDataLoader<T> = DataLoader<string, T>; | ||
import { IBaseService } from './base-service'; | ||
export type DataLoaderOptions<T> = Parameters<IBaseService<T>['getAll']>[0] & { | ||
id: string; | ||
searchKey: keyof T; | ||
}; | ||
export type IDataLoader<T> = DataLoader<string, T> & { | ||
withOptions: DataLoader<DataLoaderOptions<T>, T[]>; | ||
}; |
{ | ||
"name": "@common-stack/store-mongo", | ||
"version": "0.6.1-alpha.4", | ||
"version": "3.0.1-alpha.0", | ||
"description": "Sample core for higher packages to depend on", | ||
@@ -22,3 +22,3 @@ "license": "ISC", | ||
"dependencies": { | ||
"@common-stack/core": "0.6.1-alpha.4" | ||
"@common-stack/core": "3.0.1-alpha.0" | ||
}, | ||
@@ -35,3 +35,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "8f1002595ef0da183fc26d37a4a185b9c94cfc76" | ||
"gitHead": "2c5be38e54fcffe218106da86a39bf5c253e504d" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111876
1297
+ Added@common-stack/core@3.0.1-alpha.0(transitive)
- Removed@common-stack/core@0.6.1-alpha.4(transitive)
- Removedfractal-objects@0.10.4(transitive)