move to dexie es nedb does not support multiple isntances

This commit is contained in:
2020-10-08 20:03:09 +02:00
parent 56cd2a3e7c
commit 3f77bcf1e0
9 changed files with 40 additions and 101 deletions

View File

@@ -3,7 +3,7 @@
import day from 'dayjs'
import { range, random } from 'lodash'
import { insertLog, normalizeTimestamp, clear as clearDB } from '../../shared/db'
import { insertLog, normalizeTimestamp, DB } from '../../shared/db'
let loading = false
@@ -29,7 +29,8 @@
async function clear() {
try {
loading = true
await clearDB()
await DB.limits.clear()
await DB.logs.clear()
} finally {
loading = false
}

View File

@@ -2,7 +2,7 @@
import { createEventDispatcher } from 'svelte'
import { cloneDeep } from 'lodash'
import { Limits } from '../../shared/db'
import { DB } from '../../shared/db'
const dispatch = createEventDispatcher()
const init = { limit: ['1', 'h'], every: [1, 'd'] }
@@ -23,8 +23,7 @@
}
async function save() {
const { _id, ...rest } = limit
await Limits.update({ _id }, rest, { upsert: true })
await DB.limits.put(limit)
dispatch('update')
close()
}
@@ -41,7 +40,8 @@
<div class="content">
{#if limit}
<label class="form-label">
Host <input type="text" class="form-input" placeholder="google.com" bind:value={limit.host} />
Host
<input type="text" class="form-input" placeholder="google.com" bind:value={limit.host} />
</label>
<div class="form-label">Rules</div>