testing store interoperability (bugfixing) + notes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-08-26 18:16:07 +03:00
parent fb82119d8c
commit eec1e725d3
7 changed files with 35 additions and 9 deletions

View File

@ -25,18 +25,27 @@ var pouchdbstore = require('./pwiki/store/pouchdb')
//--------------------------------------------------------------------- //---------------------------------------------------------------------
var store = var store =
module.store = module.store = {
{ __proto__: basestore.BaseStore } // XXX base localstorage...
.nest({ __proto__: basestore.MetaStore }) __proto__: localstoragestore.localStorageStore,
__prefix__: '--pwiki-root:',
data: localStorage,
/*/
__proto__: basestore.MetaStore,
//*/
next: { __proto__: basestore.BaseStore },
}
module.setup = module.setup =
Promise.all([ Promise.all([
// static stores... // static stores...
// //
store.update('Settings', //store.next.update('System',
Object.create(basestore.BaseStore).load(page.Settings)),
store.update('System', store.update('System',
Object.create(basestore.BaseStore).load(page.System)), Object.create(basestore.BaseStore).load(page.System)),
store.update('Settings',
Object.create(basestore.BaseStore).load(page.Settings)),
store.update('Test', store.update('Test',
Object.create(basestore.BaseStore).load(page.Test)), Object.create(basestore.BaseStore).load(page.Test)),

View File

@ -1643,6 +1643,10 @@ module.System = {
<hr> <hr>
<pre wikiwords="no"><quote filter="quote-tags" src=".."/></pre> ` }, <pre wikiwords="no"><quote filter="quote-tags" src=".."/></pre> ` },
// XXX need to also be able to list things about each store...
stores: function(){
return Object.keys(this.store.substores ?? {}) },
// page parts... // page parts...
// //
'line-separator': { text: '<br>' }, 'line-separator': { text: '<br>' },
@ -1651,6 +1655,7 @@ module.System = {
// base system pages... // base system pages...
// //
// NOTE: these are last resort pages, preferably overloaded in /Templates. // NOTE: these are last resort pages, preferably overloaded in /Templates.
//
RecursionError: { RecursionError: {
text: 'RECURSION ERROR: @quote(../path)' }, text: 'RECURSION ERROR: @quote(../path)' },
NotFoundError: { NotFoundError: {

View File

@ -503,7 +503,7 @@ module.BaseStore = {
JSON.stringify(res, options.replacer, options.space) JSON.stringify(res, options.replacer, options.space)
: res }, : res },
// XXX NEXT EXPERIMENTAL... /*/ XXX NEXT EXPERIMENTAL...
nest: function(base){ nest: function(base){
return { return {
__proto__: base __proto__: base
@ -511,6 +511,7 @@ module.BaseStore = {
next: this, next: this,
data: {} data: {}
} }, } },
//*/
} }

View File

@ -520,7 +520,8 @@ module.backup = {
// XXX add monitor API + cache + live mode (auto on when lock detected)... // XXX add monitor API + cache + live mode (auto on when lock detected)...
var FileStoreRO = var FileStoreRO =
module.FileStoreRO = { module.FileStoreRO = {
__proto__: base.BaseStore, //__proto__: base.BaseStore,
__proto__: base.MetaStore,
// XXX // XXX
__path__: 'data/fs', __path__: 'data/fs',

View File

@ -20,7 +20,8 @@ var base = require('./base')
// XXX EXPERIMENTAL, needs testing in browser... // XXX EXPERIMENTAL, needs testing in browser...
var localStorageStore = var localStorageStore =
module.localStorageStore = { module.localStorageStore = {
__proto__: base.BaseStore, //__proto__: base.BaseStore,
__proto__: base.MetaStore,
__prefix__: '--pwiki:', __prefix__: '--pwiki:',
// XXX add caching of unserialized data??? // XXX add caching of unserialized data???

View File

@ -20,7 +20,8 @@ var PouchDB = require('pouchdb')
var PouchDBStore = var PouchDBStore =
module.PouchDBStore = { module.PouchDBStore = {
__proto__: base.BaseStore, //__proto__: base.BaseStore,
__proto__: base.MetaStore,
// XXX should this be __path__??? // XXX should this be __path__???
// ...this sets the path where the store is created... // ...this sets the path where the store is created...

View File

@ -1,6 +1,14 @@
/********************************************************************** /**********************************************************************
* *
* *
* XXX BUG: for some reason pwiki.get('/TestPage').raw does nothing when
* the root store is not BaseStore...
* ...seems to be a problem explicitly with /TestPage, could this
* be a name clash with /Test???
* XXX BUG service pages (*Error) now print "[ native code ]" instead of
* the path and replacing @quote(..) with @source(..) breaks things...
* ...this seems to happen only if the root store is not
* MetaStore/BaseStore...
* XXX page search: make things invariant via .names * XXX page search: make things invariant via .names
* - if a page is in a system path and there are no alternatives * - if a page is in a system path and there are no alternatives
* just return it and do not search. * just return it and do not search.