Comparing version 0.1.6 to 0.1.7
#0.1.6 | ||
* Fixed bug with count method. Added return type to get and getAll method | ||
#0.1.6 | ||
* Added count method | ||
@@ -4,0 +8,0 @@ |
@@ -22,3 +22,3 @@ import 'reflect-metadata'; | ||
*/ | ||
get(wheres: any, options?: string[]): Promise<any>; | ||
get(wheres: any, options?: string[]): Promise<T>; | ||
/** | ||
@@ -29,3 +29,3 @@ * Get all data matched the given where clause object | ||
*/ | ||
getAll(wheres?: any, options?: QueryOption): Promise<any>; | ||
getAll(wheres?: any, options?: QueryOption): Promise<T[]>; | ||
/** | ||
@@ -53,3 +53,3 @@ * Save an object to the db if not exists, else update it | ||
*/ | ||
count(wheres: any): Promise<any>; | ||
count(wheres: any): Promise<number>; | ||
} |
@@ -124,3 +124,3 @@ "use strict"; | ||
const data = yield this.db.query(statement); | ||
return data.count; | ||
return data[0].count; | ||
}); | ||
@@ -127,0 +127,0 @@ } |
{ | ||
"name": "classql", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/sorakthunly/classql/issues", |
@@ -34,3 +34,3 @@ const mysql = require('promise-mysql'); | ||
*/ | ||
public async get(wheres: any, options?: string[]): Promise<any> { | ||
public async get(wheres: any, options?: string[]): Promise<T> { | ||
if (!wheres) throw new Error(errors.where); | ||
@@ -52,3 +52,3 @@ | ||
*/ | ||
public async getAll(wheres?: any, options?: QueryOption): Promise<any> { | ||
public async getAll(wheres?: any, options?: QueryOption): Promise<T[]> { | ||
let statement = 'SELECT * FROM ' + this.table; | ||
@@ -123,3 +123,3 @@ | ||
*/ | ||
public async count(wheres: any): Promise<any> { | ||
public async count(wheres: any): Promise<number> { | ||
if (!wheres) throw new Error(errors.where); | ||
@@ -130,4 +130,4 @@ | ||
const data = await this.db.query(statement); | ||
return data.count; | ||
return data[0].count; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
48968