unimapperjs
Advanced tools
Comparing version
{ | ||
"name": "unimapperjs", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Universal node.js (native ES6/ES7) LINQ-like object mapper (ORM/ODM) for all types of databases (SQL, NoSQL).", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -117,2 +117,8 @@ import { Query } from "./Query"; | ||
/** | ||
* Check that entity with given Id exists | ||
* @param {number | string} id | ||
* @returns {Promise<boolean>} | ||
*/ | ||
static exists(id: number | string): Promise<boolean>; | ||
/** | ||
* Returns description of entity | ||
@@ -168,2 +174,9 @@ * @returns {{}} | ||
/** | ||
* Implement toJSON | ||
* @returns {{}} | ||
*/ | ||
toJSON(): { | ||
[key: string]: any; | ||
}; | ||
/** | ||
* Reset state flags | ||
@@ -170,0 +183,0 @@ */ |
@@ -168,2 +168,12 @@ "use strict"; | ||
/** | ||
* Check that entity with given Id exists | ||
* @param {number | string} id | ||
* @returns {Promise<boolean>} | ||
*/ | ||
static async exists(id) { | ||
// TODO: Create exists in adapter; Related Query.some() - use some() rather then count() after implementation | ||
// return (await this.getAll().where(x => x.id == $, id).count().exec()) == 1; | ||
return (await this.domain.__adapter.select(this, [{ func: "count", arg: null }], [{ field: ID_FIELD_NAME, func: "=", arg: id }]))[0].count == 1; | ||
} | ||
/** | ||
* Returns description of entity | ||
@@ -296,2 +306,10 @@ * @returns {{}} | ||
} | ||
// noinspection JSUnusedGlobalSymbols | ||
/** | ||
* Implement toJSON | ||
* @returns {{}} | ||
*/ | ||
toJSON() { | ||
return this.__properties; | ||
} | ||
//endregion | ||
@@ -298,0 +316,0 @@ //region Private methods |
@@ -261,2 +261,15 @@ import {Query} from "./Query"; | ||
/** | ||
* Check that entity with given Id exists | ||
* @param {number | string} id | ||
* @returns {Promise<boolean>} | ||
*/ | ||
static async exists(id: number | string): Promise<boolean> { | ||
// TODO: Create exists in adapter; Related Query.some() - use some() rather then count() after implementation | ||
// return (await this.getAll().where(x => x.id == $, id).count().exec()) == 1; | ||
return (await (<any>this.domain).__adapter.select(this, [{func: "count", arg: null}], | ||
[{field: ID_FIELD_NAME, func: "=", arg: id}]))[0].count == 1; | ||
} | ||
/** | ||
* Returns description of entity | ||
@@ -443,2 +456,11 @@ * @returns {{}} | ||
// noinspection JSUnusedGlobalSymbols | ||
/** | ||
* Implement toJSON | ||
* @returns {{}} | ||
*/ | ||
toJSON() { | ||
return this.__properties; | ||
} | ||
//endregion | ||
@@ -445,0 +467,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
296742
0.75%7469
0.67%