@mongez/mongodb
Advanced tools
Comparing version 1.0.64 to 1.0.65
@@ -45,3 +45,3 @@ "use strict"; | ||
events.collection = collection; | ||
events.trigger("aggregating", this); | ||
events.trigger("fetching", this); | ||
} | ||
@@ -48,0 +48,0 @@ /** |
@@ -6,4 +6,5 @@ export * from "./arrayOf"; | ||
export * from "./oneOf"; | ||
export * from "./random-string"; | ||
export * from "./randomInteger"; | ||
export * from "./shapedArray"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,2 +29,3 @@ "use strict"; | ||
oneOf = require("./casts/oneOf.js"), | ||
randomString = require("./casts/random-string.js"), | ||
randomInteger = require("./casts/randomInteger.js"), | ||
@@ -158,2 +159,3 @@ shapedArray = require("./casts/shapedArray.js"), | ||
exports.oneOf = oneOf.oneOf; | ||
exports.randomString = randomString.randomString; | ||
exports.randomInteger = randomInteger.randomInteger; | ||
@@ -160,0 +162,0 @@ Object.defineProperty(exports, "ShapedArrayType", { |
@@ -280,2 +280,5 @@ "use strict"; | ||
// if not changed, then do not do anything | ||
if (cast) { | ||
await this.castData(); | ||
} | ||
if (this.shouldUpdate(this.originalData, this.data) === false) { | ||
@@ -291,5 +294,2 @@ return this; | ||
} | ||
if (cast) { | ||
await this.castData(); | ||
} | ||
if (triggerEvents) { | ||
@@ -296,0 +296,0 @@ const selfModelEvents = this.getModelEvents(); |
@@ -51,11 +51,11 @@ import { ModelAggregate } from "./ModelAggregate"; | ||
*/ | ||
reassociate(this: Model, column: string, model: Model | ModelDocument, embedWith?: string): Model; | ||
reassociate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model; | ||
/** | ||
* Associate a model with the current model | ||
*/ | ||
associate(this: Model, column: string, model: Model | ModelDocument, embedWith?: string): Model; | ||
associate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model; | ||
/** | ||
* Disassociate a model with the current model | ||
*/ | ||
disassociate(this: Model, column: string, model: Model | ModelDocument): Model; | ||
disassociate(this: Model, column: string, model: Model | ModelDocument | any): Model; | ||
/** | ||
@@ -62,0 +62,0 @@ * Make a wrapper to list when models should be updated when only one of the given columns is updated |
@@ -85,3 +85,5 @@ "use strict"; | ||
const documentsList = reinforcements.clone(this.get(column, [])); | ||
const index = documentsList.findIndex((doc) => doc.id === columnValue.id); | ||
const index = documentsList.findIndex( | ||
(doc) => (doc?.id || doc) === (columnValue?.id || columnValue) | ||
); | ||
if (index === -1) { | ||
@@ -120,3 +122,5 @@ documentsList.push(columnValue); | ||
if (!Array.isArray(documentsList)) return this; | ||
const index = documentsList.findIndex((doc) => doc.id === columnValue.id); | ||
const index = documentsList.findIndex( | ||
(doc) => (doc?.id || doc) === (columnValue?.id || columnValue) | ||
); | ||
if (index !== -1) { | ||
@@ -123,0 +127,0 @@ documentsList.splice(index, 1); |
@@ -43,3 +43,3 @@ import { log } from "@mongez/logger"; | ||
events.collection = collection; | ||
events.trigger("aggregating", this); | ||
events.trigger("fetching", this); | ||
} | ||
@@ -46,0 +46,0 @@ /** |
@@ -6,4 +6,5 @@ export * from "./arrayOf"; | ||
export * from "./oneOf"; | ||
export * from "./random-string"; | ||
export * from "./randomInteger"; | ||
export * from "./shapedArray"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -107,2 +107,3 @@ export { | ||
export { oneOf } from "./casts/oneOf.js"; | ||
export { randomString } from "./casts/random-string.js"; | ||
export { randomInteger } from "./casts/randomInteger.js"; | ||
@@ -109,0 +110,0 @@ export { ShapedArrayType, shapedArray } from "./casts/shapedArray.js"; |
@@ -281,2 +281,5 @@ import { | ||
// if not changed, then do not do anything | ||
if (cast) { | ||
await this.castData(); | ||
} | ||
if (this.shouldUpdate(this.originalData, this.data) === false) { | ||
@@ -292,5 +295,2 @@ return this; | ||
} | ||
if (cast) { | ||
await this.castData(); | ||
} | ||
if (triggerEvents) { | ||
@@ -297,0 +297,0 @@ const selfModelEvents = this.getModelEvents(); |
@@ -51,11 +51,11 @@ import { ModelAggregate } from "./ModelAggregate"; | ||
*/ | ||
reassociate(this: Model, column: string, model: Model | ModelDocument, embedWith?: string): Model; | ||
reassociate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model; | ||
/** | ||
* Associate a model with the current model | ||
*/ | ||
associate(this: Model, column: string, model: Model | ModelDocument, embedWith?: string): Model; | ||
associate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model; | ||
/** | ||
* Disassociate a model with the current model | ||
*/ | ||
disassociate(this: Model, column: string, model: Model | ModelDocument): Model; | ||
disassociate(this: Model, column: string, model: Model | ModelDocument | any): Model; | ||
/** | ||
@@ -62,0 +62,0 @@ * Make a wrapper to list when models should be updated when only one of the given columns is updated |
@@ -79,3 +79,5 @@ import { clone } from "@mongez/reinforcements"; | ||
const documentsList = clone(this.get(column, [])); | ||
const index = documentsList.findIndex((doc) => doc.id === columnValue.id); | ||
const index = documentsList.findIndex( | ||
(doc) => (doc?.id || doc) === (columnValue?.id || columnValue) | ||
); | ||
if (index === -1) { | ||
@@ -113,3 +115,5 @@ documentsList.push(columnValue); | ||
if (!Array.isArray(documentsList)) return this; | ||
const index = documentsList.findIndex((doc) => doc.id === columnValue.id); | ||
const index = documentsList.findIndex( | ||
(doc) => (doc?.id || doc) === (columnValue?.id || columnValue) | ||
); | ||
if (index !== -1) { | ||
@@ -116,0 +120,0 @@ documentsList.splice(index, 1); |
{ | ||
"name": "@mongez/mongodb", | ||
"version": "1.0.64", | ||
"version": "1.0.65", | ||
"description": "Powerful Mongodb Database Manager for Node Js", | ||
@@ -9,3 +9,3 @@ "main": "./cjs/index.js", | ||
"@mongez/logger": "^1.0.9", | ||
"@mongez/reinforcements": "^2.3.6", | ||
"@mongez/reinforcements": "^2.3.7", | ||
"@mongez/supportive-is": "^1.0.12", | ||
@@ -12,0 +12,0 @@ "@mongez/time-wizard": "^1.0.6", |
381011
238
14339