mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 18:05:55 +01:00
converted note revision protection to repository/entities
This commit is contained in:
33
src/entities/entity_constructor.js
Normal file
33
src/entities/entity_constructor.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const Note = require('../entities/note');
|
||||
const NoteRevision = require('../entities/note_revision');
|
||||
const Branch = require('../entities/branch');
|
||||
const Label = require('../entities/label');
|
||||
const repository = require('../services/repository');
|
||||
|
||||
function createEntityFromRow(row) {
|
||||
let entity;
|
||||
|
||||
if (row.labelId) {
|
||||
entity = new Label(row);
|
||||
}
|
||||
else if (row.noteRevisionId) {
|
||||
entity = new NoteRevision(row);
|
||||
}
|
||||
else if (row.branchId) {
|
||||
entity = new Branch(row);
|
||||
}
|
||||
else if (row.noteId) {
|
||||
entity = new Note(row);
|
||||
}
|
||||
else {
|
||||
throw new Error('Unknown entity type for row: ' + JSON.stringify(row));
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
repository.setEntityConstructor(createEntityFromRow);
|
||||
|
||||
module.exports = {
|
||||
createEntityFromRow
|
||||
};
|
||||
Reference in New Issue
Block a user