Closed csterritt closed 7 years ago
What version are you using of gun? 0.5 or master/stable?
Oh, you already answered that, sorry. Give me a minute...
I keep getting errors with levelDOWN by itself: LevelDOWN (Module version mismatch. Expected 48, got 47
. I'll let you know when I have figured out what is going on.
@csterritt could you test to see if this works?
In a new directory do
mkdir node_modules
then
npm install gun gun-level leveldown
check to make sure that a bunch of folders exist by ls node_modules
(if it is empty something is wrong).
Then copy and paste this into a file called level.js
:
// Imports the `Gun` library
const Gun = require('gun')
// Imported for side effects, adds level adapters.
require('gun-level')
// Import the two libraries
const levelup = require('levelup')
const leveldown = require('leveldown')
// Create a new level instance which saves
// to the `data/` folder.
const levelDB = levelup('data', {
db: leveldown,
})
const gun = new Gun({
file: false,
level: levelDB,
})
const bob = gun.get('bob').put({ name: 'Bob' })
const dave = gun.get('dave').put({ name: 'Dave' })
// Write a fun circular reference.
bob.path('friend').put(dave)
dave.path('friend').put(bob)
// Print the data!
bob.path('friend.name').val()
bob.path('friend.friend.name').val()
Run it with
node level.js
There should be no errors. You should see the writes. And you can check it worked correctly by:
ls data
It should print some junk.
Did this work?
For whatever it's worth, I'm trying to stay JS-only, so I'm using jsondown, not leveldown.
Here's my package.json
file:
{
"name": "gun_test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"gun": "^0.3.9991",
"gun-level": "^4.0.1",
"jsondown": "^0.1.1",
"levelup": "^1.3.3"
}
}
Hey, that worked! I did change the 'leveldown' instances to 'jsondown', and it worked fine. Thanks!
@csterritt ahhh! That is awesome, I love staying to js-only too.
In that case... using the built in data.json
of gun is gonna be just as good as jsondown because (from https://github.com/toolness/jsondown)...
It also retains the contents of the entire JSON file in memory, so it's only really useful for debugging purposes and/or very small data stores that need just a pinch of persistence.
Which is the exact same warning we have on our data.json file.js module. So you aren't going to get any advantage using jsondown.
Note, moving forward (in 0.5?) I think that localStorage will be compatible with NodeJS localStorage polyfills. Which I think are pure JS.
Thanks for the help, and the update. I'll await 0.5 eagerly!
On Sat, Dec 17, 2016 at 4:24 PM, Mark Nadal notifications@github.com wrote:
@csterritt https://github.com/csterritt ahhh! That is awesome, I love staying to js-only too.
In that case... using the built in data.json of gun is gonna be just as good as jsondown because (from https://github.com/toolness/jsondown)...
It also retains the contents of the entire JSON file in memory, so it's only really useful for debugging purposes and/or very small data stores that need just a pinch of persistence.
Which is the exact same warning we have on our data.json file.js module. So you aren't going to get any advantage using jsondown.
Note, moving forward (in 0.5?) I think that localStorage will be compatible with NodeJS localStorage polyfills. Which I think are pure JS.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PsychoLlama/gun-level/issues/19#issuecomment-267787698, or mute the thread https://github.com/notifications/unsubscribe-auth/AACUHXTCLhF66OKQsSWDuNwc8D869M6aks5rJFLygaJpZM4LP8z5 .
Sweet! Thanks for handling this issue @amark! :smile: @csterritt did this resolve your issue?
Yup, thanks.
On Sat, Dec 17, 2016 at 4:43 PM, Jesse Gibson notifications@github.com wrote:
Sweet! Thanks for handling this issue @amark https://github.com/amark! 😄 @csterritt https://github.com/csterritt did this resolve your issue?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PsychoLlama/gun-level/issues/19#issuecomment-267788836, or mute the thread https://github.com/notifications/unsubscribe-auth/AACUHQavoMS2Z5DHzJPaTIO_i3DCvyc8ks5rJFd1gaJpZM4LP8z5 .
Cool, closing for now. If you have any further problems, feel free to reopen!
Hey - thanks for doing this. I'm trying to run the demo:
And it's doing two surprising things. First, it still writes the 'data.json' file, and second, it writes nothing in the 'data' directory (although it creates it).
This is on macOS 10.12.2, using node v6.9.1, gun 0.3.9991, and gun-level 4.0.1.
What am I doing wrong? Thanks!