Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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())
}
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
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 {*} 初始化默认值
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} 区分用户
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();
}
}
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} 区分用户
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;
db() {
return low(new LocalStorage('TheFuckingGithub'));
}
}
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
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