gun-file generates wrong .json ( Gun 0.9 )
There's a problem with how gun-file writes its json
Setup (http.js):
var Gun = require('gun/gun');
Gun.serve = require('gun/lib/serve');
require('gun/lib/ws');
require('gun-file');
....
/* server setup */
....
var gun = Gun({
'file-name' : 'data.json',
'file-pretty' : true,
web: server
});
server.listen(port);
console.log('Server started on port ' + port + ' with /gun');
var test = gun.get('testSoul').put({x:'x value'})
test.val(node => {
console.log('Gun.node.is(node) :',Gun.node.is(node) )
console.log(JSON.stringify(node))
console.log('node.x : ',node.x)
console.log('node._ : ',node._)
})
/* output */
Gun.node.is(node) : false
{"testSoul":{"_":{"#":"testSoul",">":{"x":1512422015790}},"x":"x value"}}
node.x : undefined
node._ : undefined
If i remove 'gun-file'
var Gun = require('gun/gun');
Gun.serve = require('gun/lib/serve');
require('gun/lib/ws');
//require('gun-file');
....
/* server setup */
....
var gun = Gun({
web: server
});
server.listen(port);
console.log('Server started on port ' + port + ' with /gun');
var test = gun.get('testSoul').put({x:'x value'})
test.val(node => {
console.log('Gun.node.is(node) :',Gun.node.is(node) )
console.log(JSON.stringify(node))
console.log('node.x : ',node.x)
console.log('node._ : ',node._)
})
My output is correct
Gun.node.is(node) : true
{"_":{"#":"testSoul",">":{"x":1512422851745}},"x":"x value"}
node.x : x value
node._ : { '#': 'testSoul', '>': { x: 1512422851745 } }
After removing web:server and server.listen I get the same output you do... with or without gun-file.
M:\javascript\gun-file\test>node test_2.js
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions ta
gged with 'gun'!
0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and t
ransport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.
Server started on port 0 with /gun
Gun.node.is(node) : true
{"_":{"#":"testSoul",">":{"x":1512428747643}},"x":"x value"}
node.x : x value
node._ : { '#': 'testSoul', '>': { x: 1512428747643 } }
M:\javascript\gun-file\test>node test_2.js
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions ta
gged with 'gun'!
0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and t
ransport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.
Server started on port 0 with /gun
Gun.node.is(node) : true
{"_":{"#":"testSoul",">":{"x":1512428758585}},"x":"x value"}
node.x : x value
node._ : { '#': 'testSoul', '>': { x: 1512428758585 } }
Lol... Yes, with Gun 0.8 it does work :) I'm using gun-file since you published it. So maybe i should have been clear that i'm using Gun 0.9 ;p Please try it with Gun 0.9.
Hmm I thought I had updated gun. You're right. Will get back to this soon.
Fixed; was generating input event on wrong object. pushed and published.
this was resolved for you?