How to use the lowdb/adapters/Memory 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 vuejs / vue-apollo / packages / test-ssr / apollo-server / utils / db.js View on Github external
import Lowdb from 'lowdb'
// import FileSync from 'lowdb/adapters/FileSync'
import Memory from 'lowdb/adapters/Memory'
import mkdirp from 'mkdirp'
import { resolve } from 'path'

mkdirp(resolve(__dirname, '../../live'))

// export const db = new Lowdb(new FileSync(resolve(__dirname, '../../live/db.json')))
export const db = new Lowdb(new Memory())

// Seed an empty DB
db.defaults({
  messages: [
    {
      id: 'a',
      text: 'Message 1',
    },
    {
      id: 'b',
      text: 'Message 2',
    },
    {
      id: 'c',
      text: 'Message 3',
    },
github grafoojs / grafoo / packages / test-utils / src / index.js View on Github external
function setupDB() {
  const db = low(new MemoryAdapter());

  db.defaults({ posts: [], authors: [] }).write();

  times(2, () =>
    db
      .get("authors")
      .push({
        id: casual.uuid,
        name: casual.first_name + " " + casual.last_name
      })
      .write()
  );

  db.get("authors")
    .value()
    .forEach(({ id }) => {
github grafoojs / grafoo / packages / test-utils / src / db.js View on Github external
export default function setupDB() {
  const db = low(new MemoryAdapter());

  db.defaults({ posts: [], authors: [] }).write();

  times(2, () =>
    db
      .get("authors")
      .push({
        id: casual.uuid,
        name: casual.first_name + " " + casual.last_name
      })
      .write()
  );

  db
    .get("authors")
    .value()
github dawg / vusic / packages / backend / server.spec.ts View on Github external
const makeDefaults = () => {
  const db = low(new Memory());
  const app = make(db);
  const request = supertest(app);
  return { db, app, request };
};
github gsuitedevs / md2googleslides / src / auth.ts View on Github external
private initDbSync(filePath: string): lowdb.LowdbSync {
        let adapter: lowdb.AdapterSync;
        if (filePath) {
            const parentDir = path.dirname(filePath);
            mkdirp.sync(parentDir);
            adapter = new FileSync(filePath);
        } else {
            adapter = new Memory('');
        }
        return lowdb(adapter);
    }
}
github Canner / canner / packages / canner-graphql-interface / src / connector / memoryConnector.ts View on Github external
constructor({defaultData, hooks}: {defaultData?: any, hooks?: Hooks}) {
    const adapter = new Memory();
    this.hooks = hooks || {};
    this.db = low(adapter);
    if (defaultData) {
      this.db.defaults(defaultData).write();
    }
  }
github Stepsize / atom-better-git-blame / lib / data / database.ts View on Github external
'use babel';

import low from 'lowdb';
import fs from 'fs';

import Memory from 'lowdb/adapters/Memory';
const adapter = new Memory();

const db = low(adapter);

db
  .defaults({
    commitMessages: {},
    blames: [],
    fileCommits: [],
    rootPaths: {},
    startDates: {},
    repoMetadata: {},
    pullRequests: [],
    pullRequestsCommitsPivot: {},
    issues: [],
  })
  .write();
github Stepsize / atom-better-git-blame / dist / data / database.js View on Github external
'use babel';
import low from 'lowdb';
import fs from 'fs';
import Memory from 'lowdb/adapters/Memory';
const adapter = new Memory();
const db = low(adapter);
db
    .defaults({
    commitMessages: {},
    blames: [],
    fileCommits: [],
    rootPaths: {},
    startDates: {},
    repoMetadata: {},
    pullRequests: [],
    pullRequestsCommitsPivot: {},
    githubIssues: [],
    jiraIssues: [],
})
    .write();
window.layerCacheDump = function (path = __dirname) {

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