accumulateChanges supports only a single value per attribute
Author: btheadoCreated Jun 10, 2017Updated Jun 14, 2017
I'm trying to write a watcher to persist data externally, but I'm getting the error, "accumulateChanges supports only a single value per attribute"
Here is the code (stored in file persist-test.js):
import { Program } from "witheve";
let prog = new Program("persist test");
prog.load(`
~~~
search
sort = math/range[start: 1 stop: 1]
commit
[#counter #persist sort count: 0]
~~~
`);
prog.watch("Export #persist tagged data to a tiddler", ({find, record, lookup}) => {
let rec = find("persist");
let {attribute, value} = lookup(rec);
return [
rec.add(attribute, value)
];
})
.asObjects(({adds, removes}) => {
console.log("obj add " + JSON.stringify(adds));
console.log("obj rem " + JSON.stringify(removes));
});And I'm running it like this:
node build/src/cli.js -H build/programs/persist-test.jsIf I change the watch block to instead look like this:
prog.watch("Export #persist tagged data to a tiddler", ({find, record, lookup}) => {
let counter = find("counter");
let {count, sort} = counter;
return [
record("counter", {count, sort})
];
})then I don't get the error and I get some reasonable looking output:
obj add {"tag|counter|count|0|sort|1":{"tag":"counter","sort":1,"count":0}}
obj rem {}Source: witheve/Eve