From e46963d8c14da92e8a044ed7752202c221c991fd Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 29 Apr 2018 14:37:04 +0530 Subject: [PATCH] Add groupBy in getAll --- backends/sqlite.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/sqlite.js b/backends/sqlite.js index 5f676a22..eb25f7ad 100644 --- a/backends/sqlite.js +++ b/backends/sqlite.js @@ -154,7 +154,7 @@ module.exports = class sqliteDatabase extends Database { await frappe.db.run('delete from SingleValue where parent=?', name) } - getAll({ doctype, fields, filters, start, limit, orderBy = 'modified', order = 'desc' } = {}) { + getAll({ doctype, fields, filters, start, limit, orderBy = 'modified', groupBy, order = 'desc' } = {}) { if (!fields) { fields = frappe.getMeta(doctype).getKeywordFields(); } @@ -167,6 +167,7 @@ module.exports = class sqliteDatabase extends Database { let query = `select ${fields.join(", ")} from ${doctype} ${conditions.conditions ? "where" : ""} ${conditions.conditions} + ${groupBy ? ("group by " + groupBy.join(', ')) : ""} ${orderBy ? ("order by " + orderBy) : ""} ${orderBy ? (order || "asc") : ""} ${limit ? ("limit " + limit) : ""} ${start ? ("offset " + start) : ""}`;