992b2b6ba7
Pass all queries to the dataview and use the no filters one for discovering what is the column type associated to the histogram dataview.
19 lines
633 B
JavaScript
19 lines
633 B
JavaScript
var dataviews = require('./');
|
|
|
|
var DataviewFactory = {
|
|
dataviews: Object.keys(dataviews).reduce(function(allDataviews, dataviewClassName) {
|
|
allDataviews[dataviewClassName.toLowerCase()] = dataviews[dataviewClassName];
|
|
return allDataviews;
|
|
}, {}),
|
|
|
|
getDataview: function(query, dataviewDefinition) {
|
|
var type = dataviewDefinition.type;
|
|
if (!this.dataviews[type]) {
|
|
throw new Error('Invalid dataview type: "' + type + '"');
|
|
}
|
|
return new this.dataviews[type](query, dataviewDefinition.options, dataviewDefinition.sql);
|
|
}
|
|
};
|
|
|
|
module.exports = DataviewFactory;
|