From 01a7a31a0d23eec37ea38323c81fef760583483c Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 29 Mar 2018 19:58:31 +0530 Subject: [PATCH] query builder: imperative to declarative :angry: --- backends/sqlite.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/backends/sqlite.js b/backends/sqlite.js index 83afb1f9..d959a8ab 100644 --- a/backends/sqlite.js +++ b/backends/sqlite.js @@ -74,16 +74,14 @@ module.exports = class sqliteDatabase extends Database { } getColumnDefinition(field) { - let def = `${field.fieldname} ${this.typeMap[field.fieldtype]}`; - if (field.fieldname==='name') { - def += ' PRIMARY KEY NOT NULL'; - } - else if (field.required) { - def += ' NOT NULL'; - } - if (field.default) { - def += `DEFAULT ${field.default}`; - } + let def = [ + field.fieldname, + this.typeMap[field.fieldtype], + field.fieldname === 'name' ? 'PRIMARY KEY NOT NULL' : '', + field.required ? 'NOT NULL' : '', + field.default ? `DEFAULT ${field.default}` : '' + ].join(' '); + return def; }