Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@common-stack/store-mongo

Package Overview
Dependencies
Maintainers
1
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@common-stack/store-mongo - npm Package Compare versions

Comparing version 0.5.9 to 0.5.11

21

lib/index.js

@@ -719,3 +719,6 @@ /******/ (() => { // webpackBootstrap

}
async getAll(options) {
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 })), {});
}
async getAll(options, withCount = false) {
try {

@@ -725,10 +728,10 @@ const { criteria, selectedFields, sort, limit, skip } = options;

const _a = criteria || { id: undefined }, { id } = _a, rest = __rest(_a, ["id"]);
const sortBy = (0, lodash_1.isObject)(sort) ? { [sort === null || sort === void 0 ? void 0 : sort.key]: sort.value } : interfaces_1.DEFAULT_SORTING;
const response = await this.model
.find(Object.assign(Object.assign({}, rest), (id ? { _id: id } : {})), selectedFields)
.limit(limit || interfaces_1.PAGINATION_OPTIONS.limit)
.skip(skip || interfaces_1.PAGINATION_OPTIONS.skip)
.sort(sortBy)
.exec();
return response.map((i) => i === null || i === void 0 ? void 0 : i.toObject());
const pipeline = [
{ $match: Object.assign({}, rest, id ? { _id: id } : {}) },
{ $sort: this.computeSort(sort) },
{ $skip: skip || interfaces_1.PAGINATION_OPTIONS.skip },
{ $limit: limit || interfaces_1.PAGINATION_OPTIONS.limit },
];
const data = await this.model.aggregate(pipeline);
return data.map((i) => (Object.assign({ id: i._id }, i)));
}

@@ -735,0 +738,0 @@ catch (e) {

@@ -27,2 +27,3 @@ export declare type Maybe<T> = T | null;

Time: any;
Timestamp: any;
URI: any;

@@ -29,0 +30,0 @@ URIInput: any;

@@ -10,3 +10,4 @@ import { logger as Logger } from '@cdm-logger/server';

constructor(modelFunc: (db: Connection) => Model<D>, db: Connection, logger: typeof Logger, options?: IMongoOptions);
getAll(options: GetAllArgs<D>): Promise<T[]>;
private computeSort;
getAll(options: GetAllArgs<D>, withCount?: boolean): Promise<T[]>;
private mapConditions;

@@ -13,0 +14,0 @@ count(conditions?: FilterQuery<D>): Promise<number>;

{
"name": "@common-stack/store-mongo",
"version": "0.5.9",
"version": "0.5.11",
"description": "Sample core for higher packages to depend on",

@@ -34,3 +34,3 @@ "license": "ISC",

},
"gitHead": "31a6012ca134ef9efd247a07f545e50bbee41e90"
"gitHead": "169009daff44045e999eb691f58f9dfbde1385ab"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc