How to use the lowdb/adapters/LocalStorage function in lowdb

To help you get started, we’ve selected a few lowdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github loomnetwork / plasma-cli / src / modules / db.ts View on Github external
constructor(ethereum: String, dappchain: String, plasmaAddress: String, privateKey: String) {
    // If we're on node.js
    let adapter
    if (typeof localStorage === 'undefined' || localStorage === null) {
      const low = require('lowdb')
      adapter = new FileSync(`db/db_${privateKey}.json`)
    } else {
      adapter = new LocalStorage('db')
    }
    this.db = low(adapter)
    // Initialize the database
    this.db
      .defaults({
        ethereum: ethereum,
        dappchain: dappchain,
        plasma: plasmaAddress,
        privatekey: privateKey,
        coins: []
      })
      .write()
    console.log('Initialized database', this.db.value())
  }
github d2-projects / d2-admin-start-kit / src / libs / db.js View on Github external
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
import { version } from '../../package'

const adapter = new LocalStorage(`d2admin-${version}`)
const db = low(adapter)

// 初始化数据库
db.defaults({
  themeActiveName: [],
  pageOpenedList: [],
  userInfo: [],
  isMenuAsideCollapse: [],
  database: [],
  databasePublic: {}
}).write()

export default db
github d2-projects / d2-admin-cms-go / src / utils / modules / db.js View on Github external
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
import * as cookies from './cookies'
import { cloneDeep } from 'lodash'
import env from '@/env'

const adapter = new LocalStorage(`d2admin-${env.VUE_APP_VERSION}`)
const db = low(adapter)

db
  .defaults({
    sys: {},
    database: {}
  })
  .write()

/**
 * @description 检查路径是否存在 不存在的话初始化
 * @param {Object} payload dbName {String} 数据库名称
 * @param {Object} payload path {String} 路径
 * @param {Object} payload user {Boolean} 区分用户
 * @param {Object} payload validator {Function} 数据校验钩子 返回 true 表示验证通过
 * @param {Object} payload defaultValue {*} 初始化默认值
github d2-projects / d2-admin / src / libs / util.db.js View on Github external
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
import util from '@/libs/util'
import { cloneDeep } from 'lodash'

const adapter = new LocalStorage(`d2admin-${process.env.VUE_APP_VERSION}`)
const db = low(adapter)

db
  .defaults({
    sys: {},
    database: {}
  })
  .write()

export default db

/**
 * @description 检查路径是否存在 不存在的话初始化
 * @param {Object} payload dbName {String} 数据库名称
 * @param {Object} payload path {String} 路径
 * @param {Object} payload user {Boolean} 区分用户
github Canner / canner / packages / canner-graphql-interface / src / connector / localStorageConnector.ts View on Github external
constructor({defaultData, hooks, localStorageKey}: {defaultData?: any, hooks?: Hooks, localStorageKey?: string}) {
    this.localStorageKey = localStorageKey || LocalStorageConnector.CANNER_LOCAL_STORAGE_KEY;
    const adapter = new LocalStorage(this.localStorageKey);
    this.hooks = hooks || {};
    this.db = low(adapter);
    if (defaultData) {
      this.db.defaults(defaultData).write();
    }
  }
github hank-cp / d2-admin-start-kit-plus / src / d2admin / libs / util.db.js View on Github external
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
import util from '@/d2admin/libs/util'
import { cloneDeep } from 'lodash'

const adapter = new LocalStorage(`d2admin-${process.env.VUE_APP_VERSION}`)
const db = low(adapter)

db
  .defaults({
    sys: {},
    database: {}
  })
  .write()

export default db

/**
 * @description 检查路径是否存在 不存在的话初始化
 * @param {Object} payload dbName {String} 数据库名称
 * @param {Object} payload path {String} 路径
 * @param {Object} payload user {Boolean} 区分用户
github Ice-Hazymoon / MikuTools / plugins / db.js View on Github external
import low from 'lowdb';
import LocalStorage from 'lowdb/adapters/LocalStorage';
import Vue from 'vue';
const adapter = new LocalStorage('mikudb');
const db = low(adapter);

db.defaults({
    id: '',
    noticeId: false,
    tool: {
        star_history: {}
    }
}).write();

Vue.prototype.$db = db;

export default db;
github lvxianchao / the-fucking-github / src / js / Storage.js View on Github external
db() {
        return low(new LocalStorage('TheFuckingGithub'));
    }
}
github d2-projects / d2-admin-ice / vue-materials / scaffolds / d2-admin-ice / src / libs / db.js View on Github external
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
import setting from '@/setting.js'

const adapter = new LocalStorage(`d2admin-${setting.releases.version}`)
const db = low(adapter)

db
  .defaults({
    sys: {},
    database: {}
  })
  .write()

export default db
github Qsnh / goa / static / backend / src / libs / db.js View on Github external
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
import setting from '@/setting.js'

const adapter = new LocalStorage(`d2admin-${setting.releases.version}`)
const db = low(adapter)

db
  .defaults({
    sys: {},
    database: {}
  })
  .write()

export default db

lowdb

Tiny local JSON database for Node, Electron and the browser

MIT
Latest version published 12 months ago

Package Health Score

80 / 100
Full package analysis