diff --git a/nullboard.html b/nullboard.html index b652c8a..3ce9c98 100644 --- a/nullboard.html +++ b/nullboard.html @@ -1237,6 +1237,47 @@ } } + class MultiDatabase extends Database { + constructor() + { + super(); + if (arguments.length < 1) + { + throw "must supply at least one database"; + } + this.databases = []; + for (var i=0; i { + database.set(key, value); + }); + } + + del(key) + { + this.databases.forEach((database) => { + database.del(key, value); + }); + } + + forEach(foo) + { + this.databases[0].forEach((key) => { + foo(key); + }); + } + } + class NamespacedDatabase extends Database { constructor(namespace, database) { @@ -1322,6 +1363,11 @@ } globalStorage = new NamespacedDatabase("4", new Local()); + globalStorage = new MultiDatabase( + new NamespacedDatabase("A", new Local()), + new NamespacedDatabase("B", new Local()), + ); + globalStorage = new NamespacedDatabase("B", new Local()); /* * poor man's error handling -- $fixme