Published
Edited
Sep 5, 2020
Insert cell
Insert cell
Insert cell
Insert cell
db = new loki('sandbox.db');
Insert cell
Insert cell
te_items = db.addCollection('items');
Insert cell
Insert cell
{
const btn = html`<button style="background-color:#EB9486;color:#0E0F1A" onclick=${ () => { te_items.insert({ name : 'Bob', owner: 'MON', maker: 'burgers' });}
}>Add some data to ${db.filename}</button>`
return btn;
}
Insert cell
Insert cell
viewof addData = html`<button style="background-color:#EB9486;color:#0E0F1A" >Add 4 items to database</button>`
Insert cell
// Insert some documents to the collection
// needs to test that these are present
add_data = {
addData;
let a = te_items.insert({ name : 'mjolnir', owner: 'thor', maker: 'dwarves' });
let b = te_items.insert({ name : 'gungnir', owner: 'odin', maker: 'elves' });
let c = te_items.insert({ name : 'tyrfing', owner: 'Svafrlami', maker: 'dwarves' });
let d = te_items.insert({ name : 'draupnir', owner: 'odin', maker: 'elves' });
return te_items.data // show all data that's been added
// return [a,b,c,d] // what was added
// do i even need a return ???
}
Insert cell
Insert cell
te_items.data
Insert cell
Insert cell
Insert cell
// this cell has to wait for the above cells to run.

find = {
doThis;
var tyrfing = te_items.findOne({'name': 'tyrfing'});
tyrfing.owner = 'todd';
te_items.update(tyrfing);
return (te_items.data)
}
Insert cell
Insert cell
loki = require('lokijs@1.5.11/src/lokijs.js').catch(() => window["loki"])
Insert cell
Insert cell
import {html, svg} from "@observablehq/htl"
Insert cell
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.
Learn more