CartoDB-SQL-API/batch/job_factory.js
2016-05-17 20:00:45 +02:00

23 lines
460 B
JavaScript

'use strict';
var jobModels = require('./models');
function JobFactory() {
}
module.exports = JobFactory;
JobFactory.create = function (data) {
if (!data.query) {
throw new Error('You must indicate a valid SQL');
}
for (var i = 0; i < jobModels.length; i++) {
if (jobModels[i].is(data.query)) {
return new jobModels[i](data);
}
}
throw new Error('there is no job class for the provided query');
};