►
From YouTube: p2p databases hyperbee workshop - Tom Wilson
Description
Intro workshop to p2p databases, featuring hyperbee and hyperspace, peer to peer technology in the NodeJS community. In this workshop, you will learn a little about p2p in general, but we will walk through step by step how to create a p2p database and how to access it from a remote system. This was a lot of fun, I hope you enjoy the workshop.
https://blog.hyper.io/p2p-databases-hyperbee/
Github Repos
* writer - https://github.com/twilson63/p2pdb-writer-demo
* reader - https://github.com/twilson63/p2pdb-reader-demo
A
I'm
tom
wilson
and
I
will
go
through
this
workshop
and
we're
going
to
learn
how
peer-to-peer
and
decentralized
web
kind
of
works
and
then
we're
going
to
learn
how
to
use
hyper
hyper-b
a
peer-to-peer
database,
which
is
a
little
bit
different
than
your
traditional
database
as
we
go
through
this
we'll
use
a
client
line,
application,
cli,
called
hyperspace
or
hype
and
we'll
create
a
database
we'll
connect
to
that
database,
build
a
little
app
actually
write
to
the
database
and
then
we'll
create
another
app
on
another
server
and
we'll
query
that
database
via
the
p2p
network.
A
I
think
this
will
be
really
fun
and
give
you
a
different
side
of
node.js
a
different,
a
little
bit
different
use
case
than
what
you
may
normally
use
node.js
for
so
let's
dig
in
I've
got
two
tabs
open
a
get
pod
virtual
machine,
p2p
db,
rider
one
and
another
get
pod
virtual
machine,
p2p
db
reader
one,
and
what
we're
going
to
do
is
we're
going
to
build
the
app
to
create
movies
in
our
database
on
the
writer
one
and
then
on
the
reader.
A
One
we're
going
to
build
another
app,
that's
going
to
read
that
through
the
peer-to-peer
network.
So
we'll
dig
in
to
see
how
that
all
works
and
yeah
it
should
be
a
lot
of
fun.
A
A
A
Just
having
an
internet
connection
will
create
that
accessibility,
so
we'll
be
showing
off
kind
of
the
the
work
from
hyper
protocol.
It's
a
group,
that's
focused
on
building
these
peer-to-peer
technologies
and
all
the
tools
we're
showing
are
node
modules
they
built
and
provided
for
the
community,
and
it's
really
cool.
A
So
let's
look
at
my
screen
and
we'll
get
started
so
right
here.
We've
got
a
get
pod,
which
is
just
a
virtual
machine
and
we're
going
to
first
install
the
hyperspace
cli.
So
we'll
do
npm,
install.
A
G
for
global
at
hyperspace,
cli,
slash,
cli
and
what
this
tool
is
is
just
a
way
to
to
run
the
peer-to-peer
network
client
without
you
having
to
do
a
bunch
of
things.
So
the
hyper
protocol
is
a
bunch
of
different
modules
all
composed
together,
and
this
hyperspace
cli
really
makes
it
easy
for
us
to
use
versus
having
to
know
which
modules
kind
of
combine
with
the
others
and
and
work
through
all
that.
So
with
the
hyper
space
cli,
which
is
known
as
hyp
hype,
we
can
start
the
service
in
the
background.
A
So
this
will
start
our
peer-to-peer
network
server
or
service
and
and
it's
just
a
client,
and
if
we,
you
know
kind
of
call
info,
we
can
see
that
we
don't
have
any
kind
of
projects
active
and
there's
two
kind
of
projects
that
you
can
build
on
this
peer-to-peer
network,
a
hyper
drive
which
is
a
way
to
kind
of
share
files
from
one
system
to
another
and
a
hyper
b,
which
the
b
is
kind
of
for
b
treat,
which
is
a
very
common
kind
of
database
structure.
A
So
hyper
b
is
the
database
structure
and
that's
what
we're
going
to
do,
but
before
we
do
that,
let's
just
create
a
standard
kind
of
node.js
project.
I
use
yarn,
so
I'm
going
to
do
yarn
and
knit
y
and
I'm
going
to
increase
the
size
of
the
screen
because
I'm
sure
that's
probably
hard
to
to
read.
So,
let's
see,
if
that's
a
little
bit
better.
A
Cool,
so
what
we're
going
to
do
is
just
we've
set
up
a
node.js
project.
Let's
install
some
dependencies,
the
first
imp
dependency,
we're
going
to
install,
is
express
and
then
we're
going
to
install
hyperspace,
which
is
a
node
module.
Client
that'll
allow
us
to
connect
to
the
pdp
service,
that's
running
on
our
system
and
then
hyper
b
and
hyper
b
kind
of
sits
on
top
of
hyperspace
and
it
provides
all
of
the
database
structures.
So
we're
going
to
install
those
in
our
client.
A
A
A
It's
got
a
form
where
we
can
post
a
movie
and
then
it's
got
a
place
where
we
can
list
movies
and
now
we're
going
to
create
our
express
app.
A
A
A
On
port
3000.,
so
this
is
just
a
really
contrived
demo
just
to
give
us
something
to
kind
of
visualize.
During
this
workshop,
so
we've
got
nodemon
nodemon
will
basically
restart
every
time
we
make
changes
and
we're
going
to
just
run
server.js
using
mpx.
Basically,
we
just
don't
have
to
install
it
globally.
So
now
we've
got
our
server
working
and
I'm
going
to
open
it
in
the
preview
pane
and
you
can
see
our
little
app.
A
So
we've
got
a
header,
some
movies
and
then
we've
got
a
little
form
that
we
can
add
movies
to,
and
then
we've
got
our
list
of
no
movies.
Yet
so
that's
great
now
we
just
need
one
more
thing:
we
need
to
handle
the
post
of
the
form,
so
we're
going
to
add
that
here
at
post,
slash,
request
response
and-
and
it
sends
a
json
payload,
so
we're
going
to
use
some
middleware
to
basically
convert
the
body
to
json,
we'll
use
express.json.
B
A
A
A
Li
there
we
go
now
if
we
refresh
this
page
and
we
add
ghostbusters
right
and
hit
and
it
refreshes
the
ghostbusters.
So
this
is
just
a
sample
app
to
test
our
peer-to-peer
stuff.
With
now
we're
going
to
create
a
new
to
add
all
of
our
peer-to-peer
stuff,
so
we're
gonna
create
db.js,
and
what
we
need
to
do
is
we
need
to
get
a
key
for
our
database
in
order
to
get
that
key.
A
There's
several
ways
you
can
do
it,
but
I
found
the
most
easiest
way
is
to
use
the
cli,
so
I'm
going
to
do
hype
b
or
create
b
hype
create
b,
and
that's
going
to
give
me
my
my
key
for
my
database
now.
I
can
use
that
key
in
my
code
to
access
the
database,
so
that's
kind
of
like
the
database
name.
Although
it's
a
global
hash
that,
if
you
replicate
on
a
peer-to-peer
network,
you
can
use
that
to
connect
as
we'll
see
in
the
future.
So
now,
let's
open
the
dbjs.
A
A
A
Call
this
movies
db
and
we'll
paste
our
key
in.
So
we
don't
forget
to
do
that
and
now
we're
going
to
create
our
client.
So
we're
going
to
say
new
client,
and
so
it's
a
bunch
of
modules
in
this
hyperspace
universe
and
the
client
is
the
hyperspace
client.
A
It
has
a
store
and
that
store
is
where
we're
going
to
get
a
hypercore
and
a
hypercore
is
an
impind
only
log
and
we're
going
to
put
hyper
b
on
top
of
it,
which
there's
a
lot
to
take
in
and-
and
I
understand
that-
but
but
basically
we're
going
to
use
these
underneath
peer-to-peer
technologies,
but
we're
going
to
put
a
database
kind
of
api
on
top
of
it
so
that
we
can
work
with
it
more
effectively
and
leverage
this.
A
So
with
that
we're
going
to
get
our
store,
which
will
get
it
from
the
client
and
it's
called
core
store
and
then
because
it's
kind
of
a
factory
that
creates
cores
hyper
cores.
So
we're
going
to
get
a
hyper
core
and
we're
going
to
call
store
dot,
get
and
we're
going
to
pass
it
in
our
key
up
here
so
movies
db,
and
that
will
give
us
a
hyper
core.
A
Json
and
that
hyper-v
is
a
key
value
store.
It
models
the
level
down
kind
of
api,
so
you
can
put
data,
you
can
get
data
and
you
can
list
data
or
query
data
from
a
stream.
So
we'll
we'll
work
through
that.
But
the
first
thing
we're
going
to
do
is
create
a
add
function,
so
we
want
to
do
exports,
dot,
add
equals
a
sync
function
and
we're
going
to
take
a
movie
and
then
what
we're
going
to
do
is
add
that
to
our
database,
so
we're
going
to
just
return.
A
I
have
to
put
a
weight
on
here,
but
we
can
db
put
and
we
need
some
sort
of
identifier
and
then
a
value,
so
it's
key
value.
So
the
movie
is
our
value.
We
need
an
identifier,
I'm
going
to
use
a
cu
id
because
it's
kind
of
time
based
and
we'll
get
that
from
the
cuid
module.
B
A
Okay
and
that's
our
ad
and
we'll
do
the
list
in
just
a
minute,
but
basically
we're
just
calling
db.put
and
it's
going
to
put
whatever
we
pass
as
the
movie
into
our
database.
A
B
A
A
So
if
we
do
hype
info,
we
should
see
that
we
have
our
hyper
b
running
with
three
eight
and
we
can
take
our
big
long
key
here.
We
can
do
height
dot
b
as
command
and
then
list
and
then
hyper
and
and
paste
in
this
key,
and
it
should
list
out
our
data
cool.
So
we
do
have
data
in
there.
We
have
a
id
of
this
long
cu
id
and
we
have
a
value
of
an
object
that
has
a
title
that's
groundhog
day
now
we
can
also
do
a
list
and
do.
B
A
Get
a
little
lag
here
b,
get
hyper
oops
just
copy.
A
A
A
Read
data
process
that
in
in
kind
of
the
node.js
streams
kind
of
way,
so
we're
gonna
build
that
out
and
we're
just
gonna
convert
it
to
promises,
because
that's
a
little
bit
easier
to
work
with.
A
A
A
So
we
use
this
create,
read
stream
and
you
can
add
options
in
here
and
say
greater
than
whatever
or
less
than
whatever
on
the
key.
So
if
you
use
kind
of
a
key,
you
can
do
range
queries
essentially
on
there
and
what's
cool
about
peer-to-peer
is
if
you're
a
remote
unless
there's
a
million
records
in
the
pier
that
your
database.
A
But
you
do
a
range
query
for
only
10
of
them,
then
you
only
download
10,
you
don't
download
all
a
million,
so
you
can
create
very
highly
optimized
kind
of
results
through
the
peer-to-peer
network,
which
is
pretty
cool.
So
let's
wire
this
up
and
make
sure
it
works.
So
we've
got
our
db
and
one
of
the
places
we
want
to
make
sure
it
works
is
when
we
get
our
movies.
A
And
then
we're
going
to
make
this
in
a
sync
function
and
say:
movies
equals
away
list
which
should
return
the
movies
in
their
a
list
of
objects,
and
we
want
kind
of
a
string
of
line
items.
So
in
order
to
do
that,
we're
going
to
just
simply
do
some
map
over
an
array.
So
we
get
an
array
of
objects,
we're
going
to
map
over
that
and
each
object
will
be
a
movie
and
then
we're
going
to
want
to
return
a
line.
Item
of
that
movie.
A
A
A
Now,
when
we
list,
we
should
get
the
movie.
Oh,
no,
let's
see
what
we
did
wrong.
S
is
not
defined
yeah.
A
A
Probably
optimize
this,
but
this
is
just
a
demo,
so
we're
just
going
to
keep
it
simple.
So
now,
if
we
refresh,
let's
see
what
did
we
break.
B
A
B
A
A
We
have
a
basic
database
working,
but
we
want
to
be
able
to
access
this
from
a
different
server.
So
while
it's
cool
that
we
have
this
working
on
on
this
server
or
this
pier,
we
want
to
be
able
to
read
these
movies
on
on
another
pier.
So
in
order
to
do
that,
we're
going
to
go
to
our
reader
get
pod
and
we're
gonna
do
some
similar
things.
Let
me
bump
up
the.
A
There
and
do
export
ps1,
we'll
clean
up
the
command
prompt
here.
A
Okay
and
for
this
server,
we
do
need
to
install
the
hyperspace
kind
of
node,
so
we're
going
to
do
npm,
install
global
at
hyperspace,
slash,
cli
and
then
we'll
create
a
new
project
and
instead
of
creating
kind
of
a
form,
we're
just
going
to
create
a
little
app
that
just
lists
the
movies.
A
So
we'll
model
this
after
what
we
did
in
our
writer
but
all
it'll
be
doing,
is,
is
reading
the
data
so
pretty
pretty
straightforward.
We're
gonna,
create
a
server
js
and
we're
gonna
create
a
db
js
and
the
and
then
we're
going
to
install.
A
Now,
there's
not
a
lot
of
differences
between
this
server
and
the
write
server,
so
I'm
just
going
to
kind
of
copy
the
information
instead
of
watching
me
type
all
this.
So
if
we
look
at
this
server,
really
it's
identical
right.
We
don't
need
the
ad,
so
we
can
take
that
out
and
we're
just
listing
the
movies.
We
don't
have
our
form
because,
with
the
current
setup
of
hyper
b,
it's
it's
kind
of
right
in
one
pier
and
read
in
many
different
peers.
So
that's
that's
how
we
will
be
using
it.
A
I
think,
eventually,
they're
going
to
have
the
ability
to
do
multi-writing
where
you
can
have
multiple
peers,
be
both
readers
and
writers.
But
for
now
you
have
one
writer
and
multiple
readers.
So
we've
got
that.
We
don't
need
this
because
we're
not
going
to
create
any
new
movies
in
this
one
and
yeah.
A
So
we've
got
all
that
and
now,
let's
fire
up
our
db.js
and
for
the
db.js
again
it
will
be
very
similar.
A
A
And
we're
going
to
go
back
to
our
reader
and
paste
that
key
in,
but
it's
largely
the
same
code,
we're
bringing
in
hyperspace
we're
bringing
in
hyper
b
and
we're
creating
a
client
and
a
core
store.
We've
got
our
key.
We
wrap
hyper
b
around
it
and
then
we've
got
our
list
function.
So
it's
it's
almost
exactly
the
same
code.
Now
since
we
installed
the
client,
we
haven't
started
our
node
daemon.
So
let's
start
that.
A
A
This
hash
and
we
say
hype
like
we
did
before
b
list
and
we
add
hyper
and
paste
this
hash
in
okay,
we'll
see
that
it's
not
finding
it
through
the
network
and
that's
because
we've
got
to
replicate
it.
So
let's
do
that.
Let's
go
back
to
the
writer.
A
And
we're
going
to
go
into
the
db
and
we're
going
to
add
db.ready,
which
will
basically
return
a
promise
and
when
the
peer
connection
is
initialized,
it'll
we'll
be
able
to
run
this
function
or
if
you
had
first
class
away,
you
could
just
say
a
weight,
etc,
but
we're
doing
the
dot
then
and
then
what
we
want
to
do
is
call
client
dot,
replicate
and
core
and
core
is
the
hyper
core.
A
That's
part
of
our
hyper
b.
So
we
want
to
replicate
that
and
that's
going
to
put
that
on
the
peer-to-peer
network
so
that
it
can
be
visible
for
our
peer.
A
B
A
A
So
if
we
add
a
new
movie
right,
let's
add.
A
Avengers
right
so
we
add
that
it
adds
to
the
database
here
now.
This
is
not
set
up
to
sync,
so
it
didn't
get
notified
that
something's
added,
although
you
can
do
that,
but
now,
if
we
refresh,
we
should
get
the
avengers
in
there
so
sweet
in.
In
summary,
this
is
kind
of
fun
tech,
it's
kind
of
cool
with
what
you
can
do
and
it's
all
node.js,
it's
it's
all
javascript
under
the
hood,
some
of
the
encryption
stuff
uses
a
tool
called
lib
sodium,
but
other
than
that.
A
It's
all
modules
in
the
node
ecosystem,
mainly
from
this
through
hyper
protocol
who,
if,
if
you've
been
around
the
node
system,
you
may
be
familiar
with
beaker
browser.
A
They
launched
a
prototype
with
hyperdrive
and
hyperdrive,
allows
you
to
do
peer-to-peer
websites
or
peer-to-peer
file
sharing.
Beaker
browser
allows
you
to
build
peer-to-peer
websites
which
is
really
cool
and
then
before
that
they
got
started
as
dat
and
and
kind
of
this
distributed
data
protocol.
But
everything
has
been
building
over
the
years
and
and
it's
really
exciting,
to
see
peer-to-peer
kind
of
key
value,
databases
being
built
and
so
easy
to
kind
of
access.
So
very
cool
stuff.
I
encourage
you
to
play
around
with
this
workshop.
A
Maybe
take
it
a
little
bit
further.
There's
some
guides
here
on
the
hyper
protocol,
where
you
can
actually
do
some
really
neat
stuff,
like
indexing
with
hyper
b
and
build
actually
really
nice
indexes
and
work
with
that.
But
hopefully
this
gives
you
a
good
start
and
gives
you
an
idea
of
what
you
can
do
with
hyperspace
and
hyper
b.
Thanks
for
watching
and
I'll
see
you
next
time.