@naturalcycles/db-lib
Advanced tools
Comparing version 1.23.2 to 1.24.0
@@ -0,1 +1,8 @@ | ||
# [1.24.0](https://github.com/NaturalCycles/db-lib/compare/v1.23.2...v1.24.0) (2019-09-30) | ||
### Features | ||
* DBQuery.offset ([2995253](https://github.com/NaturalCycles/db-lib/commit/2995253)) | ||
## [1.23.2](https://github.com/NaturalCycles/db-lib/compare/v1.23.1...v1.23.2) (2019-09-21) | ||
@@ -2,0 +9,0 @@ |
@@ -30,2 +30,3 @@ import { Observable } from 'rxjs'; | ||
_limitValue: number; | ||
_offsetValue: number; | ||
_orders: DBQueryOrder[]; | ||
@@ -42,2 +43,3 @@ _startCursor?: string; | ||
limit(limit: number): this; | ||
offset(offset: number): this; | ||
order(name: string, descending?: boolean): this; | ||
@@ -44,0 +46,0 @@ select(fieldNames: string[]): this; |
@@ -31,2 +31,3 @@ "use strict"; | ||
this._limitValue = 0; // 0 means "no limit" | ||
this._offsetValue = 0; // 0 means "no offset" | ||
this._orders = []; | ||
@@ -46,2 +47,6 @@ } | ||
} | ||
offset(offset) { | ||
this._offsetValue = offset; | ||
return this; | ||
} | ||
order(name, descending) { | ||
@@ -70,2 +75,3 @@ this._orders.push({ | ||
_limitValue: this._limitValue, | ||
_offsetValue: this._offsetValue, | ||
_orders: [...this._orders], | ||
@@ -90,2 +96,5 @@ _selectedFieldNames: this._selectedFieldNames && [...this._selectedFieldNames], | ||
tokens.push(...this._orders.map(o => `order by ${o.name}${o.descending ? ' desc' : ''}`)); | ||
if (this._offsetValue) { | ||
tokens.push(`offset ${this._offsetValue}`); | ||
} | ||
if (this._limitValue) { | ||
@@ -92,0 +101,0 @@ tokens.push(`limit ${this._limitValue}`); |
@@ -104,2 +104,6 @@ "use strict"; | ||
} | ||
// .offset() | ||
if (q._offsetValue) { | ||
rows = rows.slice(q._offsetValue); | ||
} | ||
// .limit() | ||
@@ -106,0 +110,0 @@ if (q._limitValue) { |
@@ -37,3 +37,3 @@ { | ||
}, | ||
"version": "1.23.2", | ||
"version": "1.24.0", | ||
"description": "Lowest Common Denominator API to supported Databases", | ||
@@ -40,0 +40,0 @@ "keywords": [ |
@@ -50,2 +50,3 @@ import { _truncate } from '@naturalcycles/js-lib' | ||
_limitValue = 0 // 0 means "no limit" | ||
_offsetValue = 0 // 0 means "no offset" | ||
_orders: DBQueryOrder[] = [] | ||
@@ -77,2 +78,7 @@ | ||
offset(offset: number): this { | ||
this._offsetValue = offset | ||
return this | ||
} | ||
order(name: string, descending?: boolean): this { | ||
@@ -105,2 +111,3 @@ this._orders.push({ | ||
_limitValue: this._limitValue, | ||
_offsetValue: this._offsetValue, | ||
_orders: [...this._orders], | ||
@@ -132,2 +139,6 @@ _selectedFieldNames: this._selectedFieldNames && [...this._selectedFieldNames], | ||
if (this._offsetValue) { | ||
tokens.push(`offset ${this._offsetValue}`) | ||
} | ||
if (this._limitValue) { | ||
@@ -134,0 +145,0 @@ tokens.push(`limit ${this._limitValue}`) |
@@ -139,2 +139,7 @@ import { _pick } from '@naturalcycles/js-lib' | ||
// .offset() | ||
if (q._offsetValue) { | ||
rows = rows.slice(q._offsetValue) | ||
} | ||
// .limit() | ||
@@ -141,0 +146,0 @@ if (q._limitValue) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
201526
3823