Snapshoting in baseX

Friday, 20 September 2013 · 2 messages · last reply 23 Sep 2013
SG
Simon Görke20 Sep 2013 10:23 #
Hi everybody, this is rather a general question than a concrete issue or a bug report: Does baseX provide any snapshoting-alike functionality, i.e. the possibility to automatically save (potentially) affected elements *before* an updating transaction is performed? We have a (existing) GUI which is used to edit data stored in a baseX database. For this GUI, we want to add undo/redo functionality for the user. Snapshoting would be a straightforward approach, but any other hints or ideas are also welcome (maybe using events?). Thanks in advance, Simon
CG
Christian Grün23 Sep 2013 11:11 #
Dear Simon, sorry for letting you wait.
Quoted text · Simon Görke · 4 lines
> this is rather a general question than a concrete issue or a bug report: > Does baseX provide any snapshoting-alike functionality, i.e. the possibility > to automatically save (potentially) affected elements > *before* an updating transaction is performed?
BaseX itself has no snapshot features included, but XQuery could be used, e. g. to store elements in second database before they are being updated by the same query. A little example:
let $entries := db:open('db')/entries
let $old := $entries/entry[@id = '...']
let $new := <new>element</new>
return (
  delete node $old,
  insert node $old into db:open('backup')/entries,
  insert node $new into $entries
)
The backup database could then be used to restore the previously changed or deleted entry. Obviously, some more logic is needed to allow more than a single undo/redo operation (you could e.g. add timestamps to your current and backed up nodes). Hope this helps, Christian
Quoted text · Simon Görke · 14 lines
> We have a (existing) GUI which is used to edit data stored in a baseX > database. For this GUI, we want to add undo/redo functionality for the user. > Snapshoting would be a straightforward approach, but any other hints or > ideas are also welcome (maybe using events?). > > Thanks in advance, > Simon > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

⚡Generated with XQuery