xpress-mongo
Advanced tools
Comparing version 0.0.29 to 0.0.30
@@ -138,3 +138,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const record = (new this()).set(data); | ||
const record = this.make(data); | ||
if (save) | ||
@@ -146,2 +146,12 @@ yield record.save(); | ||
/** | ||
* Creates instance. | ||
* @desc | ||
* Just like .new but unlike .new it does not save the record to the database it to the database | ||
* @param data - new record data. | ||
* @return {Promise<this|*>} | ||
*/ | ||
static make(data) { | ||
return (new this()).set(data); | ||
} | ||
/** | ||
* Check if id is a valid id | ||
@@ -571,3 +581,3 @@ * @param id | ||
/** | ||
* Turn data provided in query function to model instances. | ||
* Use data provided to model instance. | ||
* @param {{}} data | ||
@@ -574,0 +584,0 @@ */ |
{ | ||
"name": "xpress-mongo", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "Light Weight ODM for mongoDb", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
@@ -185,9 +185,20 @@ import ObjectCollection = require('object-collection'); | ||
*/ | ||
static async new(data: StringToAnyObject, save = true): Promise<XMongoModel> { | ||
const record = (new this()).set(data); | ||
static async new<T extends XMongoModel>(data: StringToAnyObject, save = true): Promise<T> { | ||
const record = this.make(data); | ||
if (save) await record.save(); | ||
return record; | ||
return <T>record; | ||
} | ||
/** | ||
* Creates instance. | ||
* @desc | ||
* Just like .new but unlike .new it does not save the record to the database it to the database | ||
* @param data - new record data. | ||
* @return {Promise<this|*>} | ||
*/ | ||
static make<T extends XMongoModel>(data: StringToAnyObject): T { | ||
return <T>(new this()).set(data); | ||
} | ||
/** | ||
* Check if id is a valid id | ||
@@ -698,3 +709,3 @@ * @param id | ||
/** | ||
* Turn data provided in query function to model instances. | ||
* Use data provided to model instance. | ||
* @param {{}} data | ||
@@ -701,0 +712,0 @@ */ |
@@ -96,4 +96,12 @@ import ObjectCollection = require('object-collection'); | ||
*/ | ||
static new(data: StringToAnyObject, save?: boolean): Promise<XMongoModel>; | ||
static new<T extends XMongoModel>(data: StringToAnyObject, save?: boolean): Promise<T>; | ||
/** | ||
* Creates instance. | ||
* @desc | ||
* Just like .new but unlike .new it does not save the record to the database it to the database | ||
* @param data - new record data. | ||
* @return {Promise<this|*>} | ||
*/ | ||
static make<T extends XMongoModel>(data: StringToAnyObject): T; | ||
/** | ||
* Check if id is a valid id | ||
@@ -199,3 +207,3 @@ * @param id | ||
/** | ||
* Turn data provided in query function to model instances. | ||
* Use data provided to model instance. | ||
* @param {{}} data | ||
@@ -202,0 +210,0 @@ */ |
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
127573
3464