mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	support for updating entities etc.
This commit is contained in:
		| @@ -1,11 +1,18 @@ | ||||
| "use strict"; | ||||
|  | ||||
| const Entity = require('./entity'); | ||||
| const protected_session = require('../services/protected_session'); | ||||
|  | ||||
| class Note extends Entity { | ||||
|     static get tableName() { return "notes"; } | ||||
|  | ||||
|     constructor(repository, row) { | ||||
|         super(repository, row); | ||||
|  | ||||
|         if (this.isProtected) { | ||||
|             protected_session.decryptNote(this.dataKey, this); | ||||
|         } | ||||
|  | ||||
|         if (this.isJson()) { | ||||
|             this.jsonContent = JSON.parse(this.content); | ||||
|         } | ||||
| @@ -30,6 +37,14 @@ class Note extends Entity { | ||||
|     async getTrees() { | ||||
|         return this.repository.getEntities("SELECT * FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [this.noteId]); | ||||
|     } | ||||
|  | ||||
|     beforeSaving() { | ||||
|         this.content = JSON.stringify(this.jsonContent, null, 4); | ||||
|  | ||||
|         if (this.isProtected) { | ||||
|             protected_session.encryptNote(this.dataKey, this); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| module.exports = Note; | ||||
		Reference in New Issue
	
	Block a user