Notes/src/becca/entity_constructor.js

34 lines
1007 B
JavaScript
Raw Normal View History

2023-03-16 12:17:55 +01:00
const BAttachment = require("./entities/battachment");
const BAttribute = require('./entities/battribute');
2023-06-28 21:05:31 +02:00
const BBlob = require("./entities/bblob");
const BBranch = require('./entities/bbranch');
const BEtapiToken = require('./entities/betapi_token');
2023-06-28 21:05:31 +02:00
const BNote = require('./entities/bnote');
const BOption = require('./entities/boption');
2023-06-28 21:05:31 +02:00
const BRecentNote = require('./entities/brecent_note');
2023-06-29 22:10:13 +02:00
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
};