Platform
Resources
Pricing
Sign in
Get started
Bob
Workspace
Fork
Public
By
Bob
Edited
Dec 18, 2023
Insert cell
Insert cell
PouchDB
=
require
(
"https://cdn.jsdelivr.net/pouchdb/latest/pouchdb.min.js"
)
Insert cell
db
=
new
PouchDB
(
'all_the_digitals'
)
;
Insert cell
dbFile
=
new
PouchDB
(
'File'
)
;
Insert cell
db
.
info
(
)
Insert cell
dbFile
.
info
(
)
Insert cell
newFile
=
{
return
{
_id
:
"passport"
,
g1
:
[
]
,
g2
:
[
]
}
}
Insert cell
g1
=
[
'love'
,
'peace'
,
'joy'
,
'pleasure'
,
'happiness'
]
Insert cell
g2
=
[
'harmony'
,
'cooperation'
,
'kindness'
,
'ease'
,
'fun'
]
Insert cell
viewof
saveButton
=
Inputs
.
button
(
"Save"
,
{
reduce
:
(
)
=>
fileToDB
(
)
}
)
Insert cell
fileToDB
=
(
)
=>
{
return
dbFile
.
get
(
'passport'
)
.
catch
(
(
err
)
=>
{
if
(
err
.
name
==
'not_found'
)
{
dbFile
.
put
(
newFile
)
;
return
newFile
}
else
{
// hm, some other error
throw
err
;
}
}
)
.
then
(
(
file
)
=>
{
// sweet, here is the retured file from the DB
file
.
g1
=
g1
file
.
g2
=
g2
dbFile
.
put
(
file
)
return
file
}
)
.
catch
(
(
err
)
=>
{
// handle any errors
throw
err
;
}
)
;
}
Insert cell
(
await
dbFile
.
allDocs
(
{
include_docs
:
true
}
)
)
Insert cell
dbFile
.
changes
(
{
since
:
0
,
include_docs
:
true
}
)
Insert cell
db
.
post
(
{
txt
:
"happiness"
,
list
:
2
}
)
Insert cell
(
await
db
.
allDocs
(
{
include_docs
:
true
}
)
)
.
rows
.
filter
(
i
=>
i
.
doc
.
list
==
2
)
.
map
(
i
=>
i
.
doc
.
txt
)
Insert cell
Insert cell
BrowserLevel
=
(
await
import
(
'https://cdn.jsdelivr.net/npm/browser-level@1.0.1/+esm'
)
)
.
BrowserLevel
Insert cell
bldb
=
new
BrowserLevel
(
'example'
,
{
valueEncoding
:
'json'
}
)
Insert cell
await
bldb
.
put
(
'a'
,
1
)
Insert cell
value
=
await
bldb
.
get
(
'a'
)
Insert cell
binDB
=
new
BrowserLevel
(
'binaryDB'
,
{
valueEncoding
:
'binary'
}
)
Insert cell
binaryData
=
{
// Sample binary data
let
binaryData
=
new
Uint8Array
(
[
0x48
,
0x65
,
0x6C
,
0x6C
,
0x6F
]
)
;
// Convert Uint8Array to a Buffer
//let bufferData = Buffer.from(binaryData.buffer);
return
binaryData
}
Insert cell
await
binDB
.
put
(
'binary'
,
binaryData
)
Insert cell
binaryValue
=
await
binDB
.
get
(
'binary'
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
PouchDB
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
db
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dbFile
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
newFile
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
g1
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
g2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
saveButton
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
fileToDB
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
BrowserLevel
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
bldb
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
value
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
binDB
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
binaryData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
binaryValue
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML