2021-06-29 22:15:57 +02:00
|
|
|
const Note = require('./entities/note');
|
|
|
|
const NoteRevision = require('./entities/note_revision');
|
|
|
|
const Branch = require('./entities/branch');
|
|
|
|
const Attribute = require('./entities/attribute');
|
|
|
|
const RecentNote = require('./entities/recent_note');
|
2022-01-10 17:09:20 +01:00
|
|
|
const EtapiToken = require('./entities/etapi_token');
|
2021-06-29 22:15:57 +02:00
|
|
|
const Option = require('./entities/option');
|
2018-03-31 10:51:37 -04:00
|
|
|
|
2018-08-16 23:00:04 +02:00
|
|
|
const ENTITY_NAME_TO_ENTITY = {
|
2018-08-10 14:31:57 +02:00
|
|
|
"attributes": Attribute,
|
|
|
|
"branches": Branch,
|
|
|
|
"notes": Note,
|
2020-03-14 21:09:07 +01:00
|
|
|
"note_contents": Note,
|
2018-08-10 14:31:57 +02:00
|
|
|
"note_revisions": NoteRevision,
|
2020-03-14 21:09:07 +01:00
|
|
|
"note_revision_contents": NoteRevision,
|
2018-08-10 14:31:57 +02:00
|
|
|
"recent_notes": RecentNote,
|
2022-01-10 17:09:20 +01:00
|
|
|
"etapi_tokens": EtapiToken,
|
2021-06-29 22:15:57 +02:00
|
|
|
"options": Option
|
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)) {
|
|
|
|
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
|
|
|
};
|