Commit 001cfb62 authored by Milan Wikarski's avatar Milan Wikarski 🕳

Added OFFSET option to select

parent d6c99134
Pipeline #24 canceled with stages
...@@ -74,6 +74,14 @@ class DB { ...@@ -74,6 +74,14 @@ class DB {
return ''; return '';
} }
_getOffset(offset) {
if (!isNaN(Number(offset)) && offset != null) {
return " OFFSET " + offset;
}
return "";
}
_getReturning(returning) { _getReturning(returning) {
if (typeof returning === 'string') { if (typeof returning === 'string') {
return ` RETURNING ${returning}`; return ` RETURNING ${returning}`;
...@@ -106,7 +114,7 @@ class DB { ...@@ -106,7 +114,7 @@ class DB {
); );
} }
select(tableName, columns = '*', where = null, limit = null) { select(tableName, columns = '*', where = null, limit = null, offset = null) {
let q; let q;
if (typeof columns === 'string') { if (typeof columns === 'string') {
...@@ -124,6 +132,7 @@ class DB { ...@@ -124,6 +132,7 @@ class DB {
q += this._getWhere(where); q += this._getWhere(where);
q += this._getLimit(limit); q += this._getLimit(limit);
q += this._getOffset(offset);
return this._sendResponse(q); return this._sendResponse(q);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment