orbitdb / field-manual

The Offical User's Guide to OrbitDB
207 stars 43 forks source link

Run example constructor #34

Open RichardLitt opened 5 years ago

RichardLitt commented 5 years ago

I've created a file, test.js:

const NPP = require('./newpieceplease')

NPP.onready = () => {
   console.log(NPP.orbitdb.id)
}

And I include the constructor. How do I call onready? What steps do I need more?

RichardLitt commented 5 years ago

Also:

When you ran the code in Node.js, you created two folders in your project structure: 'orbitdb/ and ipfs/.

This didn't happen for me. What am I missing?

kvutien commented 3 years ago

Excellent question, @RichardLitt , thanks for asking.

I'm doing the tutorial myself as a totally newbie to IPFS and OrbitDB. And I'm also redoing for my own usage the 01_Basics.md, eventually for a PR.

Here is a transcript of what I did, along with the output (disregard the undefined, it's coming from the JavaScript evaluator)

kvutien@VTKT5 orbitdb-ch1 % node
   Welcome to Node.js v12.18.4.
   Type ".help" for more information.
> const NPP = require('./newpieceplease')
   undefined
> NPP.onready = () => {console.log(NPP.orbitdb.id)}
   [Function]
> NPP.create()
   Promise { <pending> }
   > IPFS node's id:  03ecc23e7dfa8d1837ba979e719e934879c80dbd62fa0f42c84093f3ae53090e86
> NPP.onready()
   QmfEUEbNaTLRgLEFg6641e2ZzwWTRoY3iguwiCaqzu9W21
   undefined

Note: the output line after "Promise" is a console.log I added for my own usage.