mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	update to entity creates sync event
This commit is contained in:
		| @@ -4,6 +4,7 @@ const Entity = require('./entity'); | ||||
|  | ||||
| class Attribute extends Entity { | ||||
|     static get tableName() { return "attributes"; } | ||||
|     static get primaryKeyName() { return "attributeId"; } | ||||
|  | ||||
|     async getNote() { | ||||
|         return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ const protected_session = require('../services/protected_session'); | ||||
|  | ||||
| class Note extends Entity { | ||||
|     static get tableName() { return "notes"; } | ||||
|     static get primaryKeyName() { return "noteId"; } | ||||
|  | ||||
|     constructor(repository, row) { | ||||
|         super(repository, row); | ||||
|   | ||||
| @@ -4,6 +4,7 @@ const Entity = require('./entity'); | ||||
|  | ||||
| class NoteRevision extends Entity { | ||||
|     static get tableName() { return "note_revisions"; } | ||||
|     static get primaryKeyName() { return "noteRevisionId"; } | ||||
|  | ||||
|     async getNote() { | ||||
|         return this.repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); | ||||
|   | ||||
| @@ -4,6 +4,7 @@ const Entity = require('./entity'); | ||||
|  | ||||
| class NoteTree extends Entity { | ||||
|     static get tableName() { return "note_tree"; } | ||||
|     static get primaryKeyName() { return "noteTreeId"; } | ||||
|  | ||||
|     async getNote() { | ||||
|         return this.repository.getEntity("SELECT * FROM note_tree WHERE isDeleted = 0 AND noteId = ?", [this.noteId]); | ||||
|   | ||||
| @@ -4,6 +4,7 @@ const Note = require('../entities/note'); | ||||
| const NoteRevision = require('../entities/note_revision'); | ||||
| const NoteTree = require('../entities/note_tree'); | ||||
| const Attribute = require('../entities/attribute'); | ||||
| const sync_table = require('../services/sync_table'); | ||||
|  | ||||
| class Repository { | ||||
|     constructor(dataKey) { | ||||
| @@ -70,6 +71,10 @@ class Repository { | ||||
|         delete clone.repository; | ||||
|  | ||||
|         await sql.replace(entity.constructor.tableName, entity); | ||||
|  | ||||
|         const primaryKey = entity[entity.constructor.primaryKeyName]; | ||||
|  | ||||
|         await sync_table.addEntitySync(entity.constructor.tableName, primaryKey); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -105,6 +105,7 @@ module.exports = { | ||||
|     addImageSync, | ||||
|     addNoteImageSync, | ||||
|     addAttributeSync, | ||||
|     addEntitySync, | ||||
|     cleanupSyncRowsForMissingEntities, | ||||
|     fillAllSyncRows | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user