Browse Source

update db

main
familyfriendlymikey 2 years ago
parent
commit
0347204e97
  1. 26
      app/client.imba
  2. 22
      app/db.imba
  3. 1803
      package-lock.json
  4. 5
      package.json

26
app/client.imba

@ -1,12 +1,11 @@
let p = console.log let p = console.log
import { version } from '../package.json'
import { orderBy } from 'lodash' import { orderBy } from 'lodash'
import Dexie from 'dexie' import { version } from '../package.json'
import db from './db'
import fzi from 'fzi' import fzi from 'fzi'
import download from 'downloadjs' import download from 'downloadjs'
import 'dexie-export-import' import { nanoid } from 'nanoid'
import 'dexie-observable'
let state = { let state = {
query: '' query: ''
@ -18,20 +17,6 @@ let config = {
search_engine: {} search_engine: {}
} }
let db = new Dexie 'fuzzyhome'
db.version(1).stores({
links: "++id,name,link"
})
db.version(2).stores({
links: "$$id,name,url"
}).upgrade(do |trans|
trans.links.toCollection!.modify(do |link|
link.url = link.link
delete link.link
delete link.last_opened
)
)
global._fuzzyhome_delete_everything = do global._fuzzyhome_delete_everything = do
return unless window.confirm "This will delete everything. Are you sure?" return unless window.confirm "This will delete everything. Are you sure?"
indexedDB.deleteDatabase("fuzzyhome") indexedDB.deleteDatabase("fuzzyhome")
@ -161,9 +146,10 @@ tag app
name = name.trim! name = name.trim!
url = strip_url url url = strip_url url
let img = await fetch_image_as_base_64(url) let img = await fetch_image_as_base_64(url)
let link = { name, url, frequency, img } let id = nanoid!
let link = { id, name, url, frequency, img }
try try
await db.links.put(link) await db.links.add link
await reload_db! await reload_db!
catch e catch e
err "adding link", e err "adding link", e

22
app/db.imba

@ -0,0 +1,22 @@
import Dexie from 'dexie'
import 'dexie-export-import'
import { nanoid } from 'nanoid'
let db = new Dexie 'fuzzyhome'
db.version(1).stores({
links: "++id,name,link"
})
db.version(2).stores({
links: "++id,name,url,frequency,img"
}).upgrade! do |trans|
trans.links.toCollection!.modify! do |link|
let id = nanoid!
let name = link.name
let url = link.link
let frequency = link.frequency
let img = link.img
this.value = { id, name, url, frequency, img }
export default db

1803
package-lock.json

File diff suppressed because it is too large

5
package.json

@ -1,6 +1,6 @@
{ {
"name": "fuzzyhome", "name": "fuzzyhome",
"version": "0.1.3", "version": "0.1.4",
"scripts": { "scripts": {
"start": "imba run -SMH --baseurl . -w server.imba", "start": "imba run -SMH --baseurl . -w server.imba",
"build-app": "rm -rf dist && imba build -SMH --baseurl . server.imba", "build-app": "rm -rf dist && imba build -SMH --baseurl . server.imba",
@ -18,7 +18,8 @@
"express": "^4.17.1", "express": "^4.17.1",
"fzi": "^1.0.0", "fzi": "^1.0.0",
"imba": "^2.0.0-alpha.207", "imba": "^2.0.0-alpha.207",
"lodash": "^4.17.21" "lodash": "^4.17.21",
"nanoid": "^4.0.0"
}, },
"description": "A lightweight new-tab page that lets you very quickly fuzzy find links and navigate to a result.", "description": "A lightweight new-tab page that lets you very quickly fuzzy find links and navigate to a result.",
"homepage": "https://fuzzyho.me/", "homepage": "https://fuzzyho.me/",

Loading…
Cancel
Save