Fixes for HistoryUUID

This commit is contained in:
Magnus Åhall 2026-06-10 08:03:33 +02:00
parent be7f5dbf30
commit 3e8d5b6d9a
7 changed files with 176 additions and 18 deletions

View file

@ -57,7 +57,7 @@ export class NodeStore {
break
case 6:
nodesHistory = db.createObjectStore('nodes_history', { keyPath: ['UUID', 'Updated'] })
nodesHistory = db.createObjectStore('nodes_history', { keyPath: ['UUID', 'HistoryUUID'] })
break
case 7:
@ -471,13 +471,38 @@ class NodeHistoryStore extends SimpleNodeStore {
}
})
}// }}}
test() {
const uuid = '019ead99-984c-72b6-98f0-814991473ad6'
const lowerBound = [uuid, '']
const upperBound = [uuid, 'z']
const range = IDBKeyRange.bound(lowerBound, upperBound)
const cursor = this.db
.transaction(['nodes', this.storeName], 'readonly')
.objectStore(this.storeName)
.openCursor(range, 'prev')
cursor.onsuccess = (event) => {
const cursor = event.target.result
if (!cursor)
return
console.log(cursor.value)
cursor.continue()
}
}
retrievePage(uuid, perPage, page) {// {{{
return new Promise((resolve, _reject) => {
const lowerBound = [uuid, '00000000-0000-0000-0000-000000000000']
const upperBound = [uuid, 'ffffffff-ffff-ffff-ffff-ffffffffffff']
const range = IDBKeyRange.bound(lowerBound, upperBound)
const cursor = this.db
.transaction(['nodes', this.storeName], 'readonly')
.objectStore(this.storeName)
.index('byUUID')
.openCursor(uuid, 'prev')
.openCursor(range, 'prev')
let retrieved = 0
let first = true

View file

@ -422,6 +422,7 @@ export class Node {
async save() {//{{{
this.data.Content = this._content
this.data.Updated = new Date().toISOString()
this.data.HistoryUUID = uuidv7() // every time the node is saved a new history UUID identifies the changed node.
this._modified = false
_mbus.dispatch('NODE_UNMODIFIED')