mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-31 04:02:26 +08:00
32 lines
947 B
JavaScript
32 lines
947 B
JavaScript
const BNote = require('./entities/bnote');
|
|
const BRevision = require('./entities/brevision.js');
|
|
const BAttachment = require("./entities/battachment");
|
|
const BBranch = require('./entities/bbranch');
|
|
const BAttribute = require('./entities/battribute');
|
|
const BRecentNote = require('./entities/brecent_note');
|
|
const BEtapiToken = require('./entities/betapi_token');
|
|
const BOption = require('./entities/boption');
|
|
|
|
const ENTITY_NAME_TO_ENTITY = {
|
|
"attributes": BAttribute,
|
|
"branches": BBranch,
|
|
"notes": BNote,
|
|
"revisions": BRevision,
|
|
"attachments": BAttachment,
|
|
"recent_notes": BRecentNote,
|
|
"etapi_tokens": BEtapiToken,
|
|
"options": BOption
|
|
};
|
|
|
|
function getEntityFromEntityName(entityName) {
|
|
if (!(entityName in ENTITY_NAME_TO_ENTITY)) {
|
|
throw new Error(`Entity for table '${entityName}' not found!`);
|
|
}
|
|
|
|
return ENTITY_NAME_TO_ENTITY[entityName];
|
|
}
|
|
|
|
module.exports = {
|
|
getEntityFromEntityName
|
|
};
|