Notes/src/becca/entity_constructor.js

34 lines
1007 B
JavaScript
Raw Normal View History

const BAttachment = require('./entities/battachment');
const BAttribute = require('./entities/battribute');
const BBlob = require('./entities/bblob');
const BBranch = require('./entities/bbranch');
const BEtapiToken = require('./entities/betapi_token');
const BNote = require('./entities/bnote');
const BOption = require('./entities/boption');
const BRecentNote = require('./entities/brecent_note');
const BRevision = require('./entities/brevision');
const ENTITY_NAME_TO_ENTITY = {
2023-06-28 21:05:31 +02:00
"attachments": BAttachment,
"attributes": BAttribute,
2023-06-28 21:05:31 +02:00
"blobs": BBlob,
"branches": BBranch,
2023-06-28 21:05:31 +02:00
"etapi_tokens": BEtapiToken,
"notes": BNote,
2023-06-28 21:05:31 +02:00
"options": BOption,
"recent_notes": BRecentNote,
2023-06-28 21:05:31 +02:00
"revisions": BRevision
2018-08-09 20:08:00 +02:00
};
function getEntityFromEntityName(entityName) {
if (!(entityName in ENTITY_NAME_TO_ENTITY)) {
2023-05-04 22:16:18 +02:00
throw new Error(`Entity for table '${entityName}' not found!`);
2018-08-10 14:31:57 +02:00
}
return ENTITY_NAME_TO_ENTITY[entityName];
2018-08-09 20:08:00 +02:00
}
module.exports = {
getEntityFromEntityName
2018-08-09 20:08:00 +02:00
};