Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gun-file generates wrong .json ( Gun 0.9 ) #2

Open
Stefdv opened this issue Dec 4, 2017 · 5 comments
Open

gun-file generates wrong .json ( Gun 0.9 ) #2

Stefdv opened this issue Dec 4, 2017 · 5 comments

Comments

@Stefdv
Copy link

Stefdv commented Dec 4, 2017

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 } }
@d3x0r
Copy link
Owner

d3x0r commented Dec 4, 2017

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 } }

@Stefdv
Copy link
Author

Stefdv commented Dec 5, 2017

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.

@Stefdv Stefdv changed the title gun-file generates wrong .json gun-file generates wrong .json ( Gun 0.9 ) Dec 5, 2017
@d3x0r
Copy link
Owner

d3x0r commented Dec 5, 2017

Hmm I thought I had updated gun. You're right. Will get back to this soon.

@d3x0r
Copy link
Owner

d3x0r commented Dec 7, 2017

Fixed; was generating input event on wrong object. pushed and published.

@d3x0r
Copy link
Owner

d3x0r commented Jul 5, 2018

this was resolved for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants