xpress-mongo
Advanced tools
Comparing version 2.9.0 to 2.9.1
{ | ||
"name": "xpress-mongo", | ||
"version": "2.9.0", | ||
"version": "2.9.1", | ||
"description": "Light Weight ODM for mongoDb NodeJs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -165,3 +165,3 @@ import ObjectCollection from "object-collection"; | ||
*/ | ||
static make<T extends typeof XMongoModel>(this: T, data: StringToAnyObject): InstanceType<T>; | ||
static make<T extends typeof XMongoModel>(this: T, data?: StringToAnyObject): InstanceType<T>; | ||
/** | ||
@@ -179,2 +179,3 @@ * Check if id is a valid id | ||
private $setOriginal; | ||
private $appendData; | ||
/** | ||
@@ -181,0 +182,0 @@ * Set multiple schemas and use them at anytime using `.setSchema` |
@@ -236,4 +236,4 @@ "use strict"; | ||
*/ | ||
static make(data) { | ||
return new this().set(data); | ||
static make(data = {}) { | ||
return new this().set(data).$appendData(); | ||
} | ||
@@ -275,2 +275,16 @@ /** | ||
} | ||
$appendData(append) { | ||
// Get Append | ||
if (!append) | ||
append = this.$static().append; | ||
// If append then run append functions | ||
if (append) { | ||
for (const key of append) { | ||
if (typeof this[key] === "function") { | ||
this.set(key, this[key]()); | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
/** | ||
@@ -425,3 +439,3 @@ * Set multiple schemas and use them at anytime using `.setSchema` | ||
// @ts-ignore | ||
const append = this.constructor.append || []; | ||
const append = this.$static().append || []; | ||
const excluded = [...append, ...this.loadedRelationships]; | ||
@@ -1283,14 +1297,3 @@ for (const key in changes) { | ||
this.set(data); | ||
// Get Append | ||
if (!append) | ||
append = this.$static().append; | ||
// If append then run append functions | ||
if (append) { | ||
for (const key of append) { | ||
if (typeof this[key] === "function") { | ||
this.set(key, this[key]()); | ||
} | ||
} | ||
} | ||
return this; | ||
return this.$appendData(append); | ||
} | ||
@@ -1297,0 +1300,0 @@ /** |
111820
3429