Namespace selection for users, reports and report-templates

This commit is contained in:
Tomas Bures 2017-07-24 14:43:32 +03:00
parent 4822a50d0b
commit e7bdfb7745
16 changed files with 210 additions and 62 deletions

16
lib/namespace-helpers.js Normal file
View file

@ -0,0 +1,16 @@
'use strict';
const knex = require('./knex');
const { enforce } = require('./helpers');
const interoperableErrors = require('../shared/interoperable-errors');
async function validateEntity(tx, entity) {
enforce(entity.namespace, 'Entity namespace not set');
if (!await tx('namespaces').where('id', entity.namespace).first()) {
throw new interoperableErrors.DependencyNotFoundError();
}
}
module.exports = {
validateEntity
};