►
From YouTube: hyper63 hacking 2 10
Description
Part 3 of adding the bulk api endpoint for the data port
https://github.com/hyper63/hyper63
A
Don't
know
how
many
people
are
going
to
join
today,
but
what
we'll
do
is
go
ahead
and
get
started,
we'll
record
it,
and
then
maybe
you
can
tune
in
and
check
it
out
if
you
saw
the
last
two
streams.
Basically,
where
we
are
is
we're
working
on
issue
90
and
we're
trying
to
finish
this
bulk
endpoint
for
our
data
api.
A
We've
got
all
these
done
and
we're
in
the
process
of
implementing
the
pouch
db
adapter,
and
we
we
added
the
bulk,
add
and
wrote
a
test
for
that.
But
we
really
need
to
add
the
ability
to
update
and
delete,
and
one
of
the
things
about
that
is
is
with
pouchdb
and
couchdb.
Each
document
has
a
revision
tag
and
we're
kind
of
hiding
that
as
an
abstraction
in
hyper
63..
A
So
if
we
look
at
pouchdbs
api,
we
can
basically
go
to
get
fetch
batch
fetch
right
and
it's
this
all
docs
command
and
we
can
give
it
an
option
called
keys
and
that
keys
can
be
an
array
of
ids
and
that'll.
A
Give
us
all
the
documents
that
exist
and
what
we
want
is
not
the
entire
document,
so
we
won't
say
include
docs
true.
We
just
want
the
key
and
the
rep
and
then
we'll
iterate
through
that
and
attach
the
the
rev
to
every
document
in
the
in
the
batch
so
that
that's
kind
of
the
plan
we'll
see
how
far
we
can
go
today
with
that.
But
that
should
give
us
feature
complete
with
this,
with
the
bulk
delete
that
should
be
working.
A
A
A
Okay
and
then
we'll
go
to
our
adapter
pouchdb
and
we
can
go
into
our
adapter.js
file
with
that.
A
A
And
good
check
out,
maine
and
then
get
pool
origin
main
that
should
give
us
our
new
changes
and
then
we'll
do
get
check
out
dash
b
and
bulk
ops
db.
A
A
A
A
Okay
and
say:
hi:
okay,
so
what
do
we
got
to
do?
What
we're
doing
now
is
right
now
we're
getting
the
database,
and
then
we
got
a
little
lens
that
we're
using
to
basically
change
out
all
the
ids
to
underscore
id
and
then
removing
the
id.
So
that's
good,
so
we
get
all
the
underscore
ids
and
then
what
we
need
to
do
is
create
like
a
little
chain
here.
So
what
we
basically
want
to
do.
A
Is
is
basically,
let's
do
convert
all
the
docs
id
to
underscore
id.
Then
we
want
to
get.
A
Then
call
all
docs
to
get
all
the.
A
A
A
A
Get
well
basically
pluck.
A
A
A
Sorry
for
the
distraction,
so
we'll
we'll
get
the
docs
that
exist
and
that's
going
to
be
in
the
sink.
Also
so
we'll
chain
that
and
then
once
we
get
those
docks,
we're
going
to
map
and
merge
docks
with.
A
Bulk
docs,
okay
and
then
we'll
do
a
map
and
we
should
get
our
doc
results
and
basically
we
will
return.
Okay,
true
and
then
results,
and
you
just
want
to.
A
Okay
and
then
so,
if
we
implement
all
of
those
functions,
we
should
get
to
a
get
to
this
point
down
here
right.
So
this
gives
us
a
little
pipeline.
What
to
do?
We've
obviously
got
to
define
those
functions
and
we'll
start
with
the
switch
ids
and
we'll.
Actually,
you
know
kind
of
test
drive
this
right
because
we've
got
our
test
set
up,
so
we
should
be
able
to
run
our
test
and
validate
that
all
this
stuff
works
and
we'll
actually
start
with
just
the.
A
A
A
A
Okay,
cool,
so
everything
passed.
Let's
see
why
why
that
passed,.
A
Okay,
so
we
connect,
we
call
both
documents,
and
so
it's
funny
it's
passing
because
we've
got
okay,
true,
so
we're
not
really
checking
anything
it'll
always
pass.
The
funny
thing
is:
is
it's
returning
this?
So
what
we
want
to
do
is
we
want
to
say
the
result
should
be
okay,
so
dot,
okay
should
be
there,
so
that
should
cause
it
to
fail.
A
Cool
and
then
I'm
gonna.
A
A
Okay,
but
that's
not
what
we
want.
That's
a
good
way
to
cheat,
but
that's
not
gonna
work,
but
at
least
that
lets
us
know
that
the
async
is
running,
and
so
now
we
can
go
through
and
implement
all
of
these
functions.
So
the
first
one
is
switch
ids.
So
let's
do
that.
One.
A
But
the
the
nice
thing
about
that
is
that
it
makes
things
super
extendable
and
easy
to
test
easy
to
focus
on,
and
things
like
that.
So
we'll
call
this
switch
ids
and
what
we're
going
to
get
is
docs
right.
That's
going
to
be
our
argument
and
then
what
we
want
to
do
is
map
all
over
those
docs,
and
then
we
want
to
swap
the
lenses.
A
A
A
Okay,
now
that
we
got
that
cool,
so
we
can
see
that
it
renamed
the
id
to
underscore
id.
So
that's
cool,
that's
working
like
we
want
it
to
work
and.
A
A
And
actually
we'll
move
this
switch
ids
down
here
before
we
apply
the
bulk
docs,
because
we
really,
we
would
have
to
do
it
twice
because
we're
going
to
merge
the
docks
again
and
we'll
pull
the
docks
from
up
here.
So
if
we
just
do
the
switch
ids
after
we
merge,
the
revs
that'll
be
a
lot
easier.
A
So
clock
ids
will
take
some
docs
and
then
we
just
really
want
to
create
a
new
array
with
just
the
id.
So
this
pluck
will
actually
do
a
map
and
a
prop
at
the
same
time.
So
it's
like
map
prop
id
would
work
or
we
could
just
call
that
plug
and
either
one
of
those
would
work
just
fine
so
because
we
hadn't
renamed
them
yet
we'll
do
the
id
and
that's
a
function
in
ramda.
A
And
we'll
check
out
our
thing
up
here
and
we
do
we
got
array
one
and
two.
Now
we
can
get
those
docs
that
exists
right,
so
get
docs
that
exist,
and
so
that's
going
to
take
a
array
of
ids
and
then
we're
going
to
call.
A
Pouch
db,
but
we
want
it
to
be
in
a
sync,
so
we
need
to
kind
of
wrap
that
in
so
first
we
we
need
the
database,
so
we're
gonna
bring
that
in
we
have
manual,
curry
and
that'll,
be
the
the
database
here
that
we
called
pouch
I'll
just
call
it
pouch
just
keep
things
simple
and
then
what
we
want
to
do
is
call
pouch.all
docs,
but
we
want
to
convert
this
promise
into
an
async
data
type.
A
So
we're
going
to
say,
pouch
dot,
all
docs
dot
bind
dot
pouch,
so
it
keeps
bound
to
the
instance,
but
it
converts
it
to
a
promise
or
or
in
a
sync
data
type,
and
then
now
we
can
kind
of
give
it
our
argument.
So
we
want
to
call
all
docs
and
say
keys
equals
ids,
and
that
should
return
us
some
results.
So,
let's
see
what
that
gives
us.
A
Okay,
so
it's
creating
a
database
and
what
we
just
need
to
do
is
kind
of
set
up
the
database
by
adding
a
document.
So
what
we'll
do
is.
A
A
A
A
We
got
value
of
an
object,
so
let's
go
down
here.
A
A
Let's
just
print
out:
oh
let's
do
it
this
way.
This
would
be
easier,
we'll
just
map
pluck
value.
A
A
A
There
we
go
okay,
so
we
got
our
value
and
it's
got
a
rev
in
it.
So
so
really
we
want
to
kind
of
go
through
these
rows
and
really
create
an
array
that
you
know
has
for
each
record
a
key
and
a
rep
right.
If,
if
it's
not
I
mean,
if
it,
there
is
a
value,
so
we
want
to
kind
of
transform
this
or
really
what
we
could
do.
A
A
Matt,
so
we
get
a
result
back
so
we
need
to
get
the
prop
rows
and
then
we
need
to.
A
A
Lambda
function
that
just
really
checks
and
each
object,
and
if
it
has
a
prop
value,
then
it
keeps
it
if
it
doesn't
have
a
prop
value:
it'll
get
rid
of
it.
So
let's
go
up
here
and
make
sure
we've
got
haz.
A
A
Okay
cool,
so
it
only
kept
number
two,
that's
good!
Now
we
need
to
change
this
object.
We
want
the
id
and
the
rev
so
to
transform
that
and
we'll
just
write
that
out
by
hand,
because
it'll
probably
be
easier
to
understand,
we're
going
to
map
over
each
object
and
we're
just
going
to
we're
what
we're
going
to
do
is
do
like
we
did
up
here
with
switch
ids,
we're
going
to
say
compose
well.
First,
we
need
to
map
over
each
object.
A
We're
going
to
do
lens,
rev,
we'll
call
it
lens
rev,
and
what
we're
going
to
do
is
read
the
value,
dot,
rev
property
and
write
to
the
rev
property.
So
with
that
we're
just
going
to
write
whatever
value
it
passes
us
into
the
rev
property,
so
we'll
compose.
A
Like
that-
and
we
just
have
to
build
this
lens-
rev
wet
lens
rev
and
we're
going
to
say
path
and
with
path,
we're
going
to
give
it
the
value
and
the
rev
right,
because
that's
what
we
want
to
read
and
then
we're
going
to
say
associate
where
we
want
to
write-
and
this
will
be
the
rev
property
like
that,
and
we
gotta
make
sure
we
have
the
path
defined.
A
A
Cool,
so
we
transformed
it
where
we
have
id
in
rev
perfect.
So
that's
our
get
docs
that
exist
little
function
and
you
know
we
could
pull
that
out
into
a
little
function.
If
we
wanted
to.
A
A
A
A
So
what
I'll
do
merge
with
reds
and
with
this
one
we're
going
to
get
the
docs,
and
then
we
have
our
array
of
ids
that
match
here
and
what
we
can
do
is
essentially
map
over
the
docs
and
then,
if
this
id
matches
in
this
list,
so
we
can
do
a
fine,
and
if
we
find
that,
then
we
can
add
the
red.
So
that's
probably
the
easiest
way
for
now.
A
We
really
probably
could
do
a
reduce
here
but
short
on
time.
So
I
think
we'll
just
do
a
find
and
then
then
we'll
come
back
later
and
and
add
a
reduce
if
it
makes
more
sense,
but
basically.
A
A
A
A
A
A
That
has
the
rev
and
I
think
it's
underscore
web
is
what
we
want
and
it
will
have
rev.rev
and
then
we
want
to
include
the
dock.
Otherwise
we
just
return
the
dock.
A
A
A
A
Cool
so
we've
got
the
id2
and
we
got
the
rep,
so
we
put
pop
the
rev
in
our
docs
list
and
now
we've
got
a
list
of
documents
again
because
you'll
see
our
id1.
So
that's
good.
Now
what
we
need
to
do
is
switch
ids,
which
we've
already
done
a
so
this
should
be
easy.
So
now
we
should
get
under
score
id
and
underscore
rev
and
let's
put
some
more
data
in
there
just
so
we
can
make
sure
it's
keeping
that
so.
I'm
gonna
open
adapter
tests
and
let's.
A
A
Pipe
movie
title
ghostbusters.
A
A
A
Basically,
that's
what
we
did,
but
we
need
to
make
it
a
sync
function.
So
we'll
do
apply.
A
Docs
like
that,
and
we're
going
to
get
the
docs
and
we're
going
to
want
to
return
a
sink
from
promise
and
we'll
need
our
pouch
database
here
so
we'll
say:
pouch
dot,
vault,
docs
dot
bind
pouch
and
that
will
create
our
a
sync
function
and
then
we
can
just
pass
it.
The
docs
so
do
that
and
that
should
work.
A
A
Cool,
so
we
got
them
both
applied.
How
nice
that's
really
cool,
we'll
notice
this
rev
incremented,
so
we
went
from,
we
actually
did
an
update,
and
now
we
need
to
omit
the
rev
and
return
the
results.
A
A
A
A
And
we
got
it
and
everything's
passing
so
we
will
need
to
do
some
cleanup,
really
quick.
A
And
just
add
a
little
bit
more
on
the
test,
so
one
of
the
things
we
want
to
do
is:
if
we
get
our
result,
we
want
to
just
remove
that
document.
A
A
And
make
sure
that's
still
working
okay,
db
name
is
not
defined.
It's
capital,
n.
A
So
that's
our
our
cleanup
and
then
let's
uncomment,
these
out.
A
Now
we
could
validate
the
ids
that
we're
getting,
but
I
think
we're
we're.
Okay,
we
can
always
log
that
out
and
the
other
thing
is
we
need
to
test
delete,
but
we're
kind
of
running
out
of
time.
A
A
A
A
A
A
A
A
You
know,
I
wonder
if
it's
deleting
it
it,
I
think
it
is
deleting
it
it's
just
coming
back
saying
that
it
executed
that
that
thing
correctly.
So,
let's
we
can
verify
that.
But
let's
make
this
right
and
then
before
we
remove.
A
Okay,
let's
just
away.
A
A
Cool,
so
we
did,
we
did
delete
it,
and
it
just
shows
up
here
because
it
was
successfully
processed.
A
A
We're
on
bulk
patch
four,
what
we
want
to
do
is
increment
the
version,
so
we'll
say
npm
version
and
patch.
Now
I'll
change
this
to
one
one.
Seven.
A
A
And
get
status,
let's
do.
A
A
A
A
Push
origin
and
bulk
plus
db4,
and
there
we
go.
We've
got
that
feature
knocked
out,
we'll
create
a
pr.
A
Check
that
check
that
and
then
I
guess
tomorrow
we'll
work
on
the
couchdb
adapter,
but
that
feels
good,
hopefully
all
of
our
tests
patch
pass.
So
they
did
that's
pretty
cool
and
thank
you
for
joining
me
and
we'll
do
this
again
tomorrow,
at
4,
30
have
a
good.