From ef5049f28f5a57e9610e2c8a50e99b66280de61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 15 Sep 2017 14:07:46 +0200 Subject: [PATCH] Use destructuring assignment to improve readability --- lib/cartodb/models/dataview/factory.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/models/dataview/factory.js b/lib/cartodb/models/dataview/factory.js index 6ad65312..fa55641c 100644 --- a/lib/cartodb/models/dataview/factory.js +++ b/lib/cartodb/models/dataview/factory.js @@ -9,10 +9,12 @@ module.exports = class DataviewFactory { } static getDataview (query, dataviewDefinition) { - const type = dataviewDefinition.type; + const { type, options, sql } = dataviewDefinition; + if (!this.dataviews[type]) { throw new Error('Invalid dataview type: "' + type + '"'); } - return new this.dataviews[type](query, dataviewDefinition.options, dataviewDefinition.sql); + + return new this.dataviews[type](query, options, sql); } };