@common-stack/store-mongo
Advanced tools
Comparing version 0.5.11 to 0.5.12
@@ -166,3 +166,3 @@ /******/ (() => { // webpackBootstrap | ||
Object.defineProperty(exports, "__esModule", ({ value: true })); | ||
exports.DEFAULT_SORTING = exports.PAGINATION_OPTIONS = void 0; | ||
exports.PAGINATION_OPTIONS = void 0; | ||
var PAGINATION_OPTIONS; | ||
@@ -173,5 +173,2 @@ (function (PAGINATION_OPTIONS) { | ||
})(PAGINATION_OPTIONS = exports.PAGINATION_OPTIONS || (exports.PAGINATION_OPTIONS = {})); | ||
exports.DEFAULT_SORTING = { | ||
id: 'asc', | ||
}; | ||
@@ -722,3 +719,6 @@ | ||
computeSort(sort) { | ||
return (0, lodash_1.isObject)(sort) ? { [sort === null || sort === void 0 ? void 0 : sort.key]: sort.value.toLowerCase() === 'asc' ? 1 : -1 } : Object.entries(interfaces_1.DEFAULT_SORTING).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [key]: value.toLowerCase() === 'asc' ? 1 : -1 })), {}); | ||
if ((0, lodash_1.isObject)(sort)) { | ||
return { [sort === null || sort === void 0 ? void 0 : sort.key]: sort.value.toLowerCase() === 'asc' ? 1 : -1 }; | ||
} | ||
return null; | ||
} | ||
@@ -732,3 +732,3 @@ async getAll(options, withCount = false) { | ||
{ $match: Object.assign({}, rest, id ? { _id: id } : {}) }, | ||
{ $sort: this.computeSort(sort) }, | ||
...(sort ? [{ $sort: this.computeSort(sort) }] : []), | ||
{ $skip: skip || interfaces_1.PAGINATION_OPTIONS.skip }, | ||
@@ -735,0 +735,0 @@ { $limit: limit || interfaces_1.PAGINATION_OPTIONS.limit }, |
@@ -1,2 +0,2 @@ | ||
import { FilterQuery, Document, Model, UpdateQuery } from 'mongoose'; | ||
import { Document, FilterQuery, Model, UpdateQuery } from 'mongoose'; | ||
import { GetAllArgs } from './get-all-args'; | ||
@@ -7,5 +7,2 @@ export declare enum PAGINATION_OPTIONS { | ||
} | ||
export declare const DEFAULT_SORTING: { | ||
id: string; | ||
}; | ||
export interface IBaseRepository<T, D = Document<T>> { | ||
@@ -12,0 +9,0 @@ model: Model<D>; |
{ | ||
"name": "@common-stack/store-mongo", | ||
"version": "0.5.11", | ||
"version": "0.5.12", | ||
"description": "Sample core for higher packages to depend on", | ||
@@ -34,3 +34,3 @@ "license": "ISC", | ||
}, | ||
"gitHead": "169009daff44045e999eb691f58f9dfbde1385ab" | ||
"gitHead": "f69aae83248fd9b740388e39d5a3ce44b05bca81" | ||
} |
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
93538
1154