When I stop my node clients and restart it all documents are reported to the node, not just updated ones.
{"docKey":"12345678789","counter":11}
Object { foo: "bar", counter: 12 }
counter: 12
foo: "bar"
}
In the client although it has received already all previous event until counter 11 I still see:
getting a new document {
_: {
'#': 'testkey',
'>': { counter: 1705088678010, foo: 1705088678010 }
},
counter: 3,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":0}',
'>': { counter: 1705088820172, foo: 1705088820172 }
},
counter: 1,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":10}',
'>': { counter: 1705089016708, foo: 1705089016708 }
},
counter: 11,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":11}',
'>': { counter: 1705089098084, foo: 1705089098084 }
},
counter: 12,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":12}',
'>': { counter: 1705089299089, foo: 1705089299089 }
},
counter: 13,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":1}',
'>': { counter: 1705088827644, foo: 1705088827644 }
},
counter: 2,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":2}',
'>': { counter: 1705088829660, foo: 1705088829660 }
},
counter: 3,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":3}',
'>': { counter: 1705088911366, foo: 1705088911366 }
},
counter: 4,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":4}',
'>': { counter: 1705088912461, foo: 1705088912461 }
},
counter: 5,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":5}',
'>': { counter: 1705088914236, foo: 1705088914236 }
},
counter: 6,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":6}',
'>': { counter: 1705088929828, foo: 1705088929828 }
},
counter: 7,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":7}',
'>': { counter: 1705089012617, foo: 1705089012617 }
},
counter: 8,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":8}',
'>': { counter: 1705089015268, foo: 1705089015268 }
},
counter: 9,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":9}',
'>': { counter: 1705089016028, foo: 1705089016028 }
},
counter: 10,
foo: 'bar'
}
getting a new document {
_: {
'#': 'testkey',
'>': { counter: 1705088678010, foo: 1705088678010 }
},
counter: 3,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":0}',
'>': { counter: 1705088820172, foo: 1705088820172 }
},
counter: 1,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":10}',
'>': { counter: 1705089016708, foo: 1705089016708 }
},
counter: 11,
foo: 'bar'
}
getting a new document {
_: {
'#': '{"docKey":"12345678789","counter":11}',
'>': { counter: 1705089098084, foo: 1705089098084 }
},
counter: 12,
foo: 'bar'
}
...
</style>
<div>
<input id="collection" readonly placeholder="collection" value="testdata">
</input>
</div>
<div>
<textarea id="key" rows="5" placeholder="document key">
{
"docKey": "12345678789"
}
</textarea>
</div>
<div>
<textarea id="document" rows="25" placeholder="document">
{
"foo": "bar"
}
</textarea>
</div>
<button onclick="save()">Save</button>
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script><script>
gun = Gun(['http://localhost:9999/gun']);
let counter = 0
function save() {
const doc = document.getElementById('document').value;
const collection = document.getElementById('collection').value;
let key = document.getElementById('key').value;
let _key = JSON.parse(key)
_key.counter = counter++;
key = JSON.stringify(_key)
console.log("add key", key)
let _doc = JSON.parse(doc)
_doc.counter = counter
let ref = gun.get(key).put(_doc)
console.log("doc", _doc)
gun.get(collection).set(ref)
}
</script>
Open this in a browser.
When I stop my node clients and restart it all documents are reported to the node, not just updated ones.
Example I add while my node client is not running I add:
In the client although it has received already all previous event until counter 11 I still see:
My
test.htmlcreating data:Open this in a browser.
My Gun proxy
server.js:Start with:
In the same dir my test peer
test.jsrunning inside node:Start with: