Socket
Socket
Sign inDemoInstall

@mongez/mongodb

Package Overview
Dependencies
232
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.71 to 1.0.72

1

cjs/aggregate/expressions.d.ts

@@ -0,1 +1,2 @@

import { GenericObject } from "@mongez/reinforcements";
/**

@@ -2,0 +3,0 @@ * Get count expression

@@ -82,3 +82,8 @@ import { GenericObject } from "@mongez/reinforcements";

*/
static baseSchemaWith(schema: GenericObject): any;
static baseSchemaWith(schema: GenericObject): {
_id: any;
id: string;
createdAt: DateConstructor;
updatedAt: DateConstructor;
};
}

@@ -85,0 +90,0 @@ /**

2

cjs/casts/random-string.d.ts

@@ -1,2 +0,2 @@

export declare function randomString(length?: number): () => any;
export declare function randomString(length?: number): () => string;
//# sourceMappingURL=random-string.d.ts.map

@@ -37,3 +37,3 @@ import { MongoClient, MongoClientOptions } from "mongodb";

*/
on(eventName: ConnectionEvent, callback: any): any;
on(eventName: ConnectionEvent, callback: any): import("@mongez/events").EventSubscription;
/**

@@ -40,0 +40,0 @@ * Use another database

@@ -56,7 +56,7 @@ import { Database } from "../database";

*/
static getIncrementIdBy(): any;
static getIncrementIdBy(): number;
/**
* Get initial id
*/
static getInitialId(): any;
static getInitialId(): number;
/**

@@ -63,0 +63,0 @@ * Generate next id

@@ -34,2 +34,10 @@ import { BaseModel } from "./base-model";

/**
* Get deleted document by id
*/
static getDeleted<T>(this: ChildModel<T>, id: PrimaryIdType): Promise<T | null>;
/**
* Get all deleted documents
*/
static getAllDeleted<T>(this: ChildModel<T>, filter?: Filter): Promise<any>;
/**
* Find and update the document for the given filter with the given data or create a new document/record

@@ -36,0 +44,0 @@ * if filter has no matching

@@ -77,2 +77,3 @@ "use strict";

const model = this.self(document);
model.unset("deletedAt");
model.markAsRestored();

@@ -119,2 +120,48 @@ await model.save(); // save again in the same collection

/**
* Get deleted document by id
*/
static async getDeleted(id) {
const deleteStrategy = this.deleteStrategy;
if (deleteStrategy === types.ModelDeleteStrategy.softDelete) {
const model = await this.query.first(this.collection, {
id,
});
if (!model) return null;
return model;
}
const result = await this.query.first(
this.collection + "Trash",
this.prepareFilters({
[this.primaryIdColumn]: id,
})
);
if (!result) return null;
const document = result.document;
// otherwise, create a new model with it
const model = this.self(document);
return model;
}
/**
* Get all deleted documents
*/
static async getAllDeleted(filter) {
const deleteStrategy = this.deleteStrategy;
if (deleteStrategy === types.ModelDeleteStrategy.softDelete) {
return await this.query.list(this.collection, filter);
}
if (filter) {
for (const key in filter) {
filter[`document.` + key] = filter[key];
delete filter[key];
}
}
const documents = await this.query.list(this.collection + "Trash", filter);
const models = [];
for (const document of documents) {
const model = this.self(document.document);
models.push(model);
}
return models;
}
/**
* Find and update the document for the given filter with the given data or create a new document/record

@@ -121,0 +168,0 @@ * if filter has no matching

@@ -95,3 +95,3 @@ import { AggregateOptions, CountDocumentsOptions, ExplainVerbosityLike, FindCursor, FindOptions, UpdateFilter, UpdateOptions } from "mongodb";

*/
trigger(eventName: string, payload?: Record<string, any>): Promise<any[]>;
trigger(eventName: string, payload?: Record<string, any>): Promise<import("@mongez/events").EventTriggerResponse[]>;
/**

@@ -98,0 +98,0 @@ * Listen on creating event

@@ -0,1 +1,2 @@

import { GenericObject } from "@mongez/reinforcements";
/**

@@ -2,0 +3,0 @@ * Get count expression

@@ -82,3 +82,8 @@ import { GenericObject } from "@mongez/reinforcements";

*/
static baseSchemaWith(schema: GenericObject): any;
static baseSchemaWith(schema: GenericObject): {
_id: any;
id: string;
createdAt: DateConstructor;
updatedAt: DateConstructor;
};
}

@@ -85,0 +90,0 @@ /**

@@ -1,2 +0,2 @@

export declare function randomString(length?: number): () => any;
export declare function randomString(length?: number): () => string;
//# sourceMappingURL=random-string.d.ts.map

@@ -37,3 +37,3 @@ import { MongoClient, MongoClientOptions } from "mongodb";

*/
on(eventName: ConnectionEvent, callback: any): any;
on(eventName: ConnectionEvent, callback: any): import("@mongez/events").EventSubscription;
/**

@@ -40,0 +40,0 @@ * Use another database

@@ -56,7 +56,7 @@ import { Database } from "../database";

*/
static getIncrementIdBy(): any;
static getIncrementIdBy(): number;
/**
* Get initial id
*/
static getInitialId(): any;
static getInitialId(): number;
/**

@@ -63,0 +63,0 @@ * Generate next id

@@ -34,2 +34,10 @@ import { BaseModel } from "./base-model";

/**
* Get deleted document by id
*/
static getDeleted<T>(this: ChildModel<T>, id: PrimaryIdType): Promise<T | null>;
/**
* Get all deleted documents
*/
static getAllDeleted<T>(this: ChildModel<T>, filter?: Filter): Promise<any>;
/**
* Find and update the document for the given filter with the given data or create a new document/record

@@ -36,0 +44,0 @@ * if filter has no matching

@@ -75,2 +75,3 @@ import { ObjectId } from "mongodb";

const model = this.self(document);
model.unset("deletedAt");
model.markAsRestored();

@@ -117,2 +118,48 @@ await model.save(); // save again in the same collection

/**
* Get deleted document by id
*/
static async getDeleted(id) {
const deleteStrategy = this.deleteStrategy;
if (deleteStrategy === ModelDeleteStrategy.softDelete) {
const model = await this.query.first(this.collection, {
id,
});
if (!model) return null;
return model;
}
const result = await this.query.first(
this.collection + "Trash",
this.prepareFilters({
[this.primaryIdColumn]: id,
})
);
if (!result) return null;
const document = result.document;
// otherwise, create a new model with it
const model = this.self(document);
return model;
}
/**
* Get all deleted documents
*/
static async getAllDeleted(filter) {
const deleteStrategy = this.deleteStrategy;
if (deleteStrategy === ModelDeleteStrategy.softDelete) {
return await this.query.list(this.collection, filter);
}
if (filter) {
for (const key in filter) {
filter[`document.` + key] = filter[key];
delete filter[key];
}
}
const documents = await this.query.list(this.collection + "Trash", filter);
const models = [];
for (const document of documents) {
const model = this.self(document.document);
models.push(model);
}
return models;
}
/**
* Find and update the document for the given filter with the given data or create a new document/record

@@ -119,0 +166,0 @@ * if filter has no matching

@@ -95,3 +95,3 @@ import { AggregateOptions, CountDocumentsOptions, ExplainVerbosityLike, FindCursor, FindOptions, UpdateFilter, UpdateOptions } from "mongodb";

*/
trigger(eventName: string, payload?: Record<string, any>): Promise<any[]>;
trigger(eventName: string, payload?: Record<string, any>): Promise<import("@mongez/events").EventTriggerResponse[]>;
/**

@@ -98,0 +98,0 @@ * Listen on creating event

{
"name": "@mongez/mongodb",
"version": "1.0.71",
"version": "1.0.72",
"description": "Powerful Mongodb Database Manager for Node Js",

@@ -5,0 +5,0 @@ "main": "./cjs/index.js",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc