2024-02-17 11:16:00 +02:00
|
|
|
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');
|
2018-03-31 10:51:37 -04:00
|
|
|
|
2018-08-16 23:00:04 +02:00
|
|
|
const ENTITY_NAME_TO_ENTITY = {
|
2023-06-28 21:05:31 +02:00
|
|
|
"attachments": BAttachment,
|
2023-01-03 13:52:37 +01:00
|
|
|
"attributes": BAttribute,
|
2023-06-28 21:05:31 +02:00
|
|
|
"blobs": BBlob,
|
2023-01-03 13:52:37 +01:00
|
|
|
"branches": BBranch,
|
2023-06-28 21:05:31 +02:00
|
|
|
"etapi_tokens": BEtapiToken,
|
2023-01-03 13:52:37 +01:00
|
|
|
"notes": BNote,
|
2023-06-28 21:05:31 +02:00
|
|
|
"options": BOption,
|
2023-01-03 13:52:37 +01:00
|
|
|
"recent_notes": BRecentNote,
|
2023-06-28 21:05:31 +02:00
|
|
|
"revisions": BRevision
|
2018-08-09 20:08:00 +02:00
|
|
|
};
|
|
|
|
|
2018-08-16 23:00:04 +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
|
|
|
}
|
|
|
|
|
2018-08-16 23:00:04 +02:00
|
|
|
return ENTITY_NAME_TO_ENTITY[entityName];
|
2018-08-09 20:08:00 +02:00
|
|
|
}
|
|
|
|
|
2018-03-31 10:51:37 -04:00
|
|
|
module.exports = {
|
2018-08-16 23:00:04 +02:00
|
|
|
getEntityFromEntityName
|
2018-08-09 20:08:00 +02:00
|
|
|
};
|