How to use the @nozbe/watermelondb/adapters/lokijs function in @nozbe/watermelondb

To help you get started, we’ve selected a few @nozbe/watermelondb 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 AliAllaf / firemelon / src / utils / schema.ts View on Github external
export default function newDatabase() {
    const adapter = new LokiJSAdapter({
        schema,
    });
    const database = new Database({
        actionsEnabled: true,
        adapter,
        // @ts-ignore
        modelClasses: [Todo, User],
    });

    return database;
}
github johannesjo / super-productivity / src / app / core / watermelon / watermelon.service.ts View on Github external
import {Injectable} from '@angular/core';
import {Database} from '@nozbe/watermelondb';
import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs';

import schema from './schema';
import TaskMelon from './task';
import {Observable} from 'rxjs';

// First, create the adapter to the underlying database:
// const adapter = new SQLiteAdapter({
//   schema,
// })
const adapter = new LokiJSAdapter({
  schema,
});

const modelClasses = [
  TaskMelon as any,
];


@Injectable({
  providedIn: 'root'
})
export class WatermelonService {
  db = new Database({
    adapter,
    modelClasses,
    actionsEnabled: true,
github Nozbe / WatermelonDB / examples / web / src / index.js View on Github external
import React from 'react'
import { render } from 'react-dom'

import { Database } from '@nozbe/watermelondb'
import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs'
import DatabaseProvider from '@nozbe/watermelondb/DatabaseProvider'

import { mySchema } from 'models/schema'
import Blog from 'models/Blog'
import Post from 'models/Post'
import Comment from 'models/Comment'

import Root from 'components/Root'

const adapter = new LokiJSAdapter({
  dbName: 'WatermelonDemo',
  schema: mySchema,
})

const database = new Database({
  adapter,
  modelClasses: [Blog, Post, Comment],
  actionsEnabled: true,
})

render(
  
    
  , document.getElementById('application')
)
github status-im / liquid-funding / src / db.js View on Github external
import { Database } from '@nozbe/watermelondb'
import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs'

import schema from './model/schema'
import LpEvent from './model/lpEvents'
import VaultEvent from './model/vaultEvent'
import Profile from './model/profile'
import Pledge from './model/pledge'
import Delegate from './model/delegate'

const dbName = 'LiquidFunding'

const adapter = new LokiJSAdapter({
  dbName,
  schema,
})

const database = new Database({
  adapter,
  modelClasses: [
    LpEvent,
    VaultEvent,
    Profile,
    Pledge,
    Delegate
  ],
  actionsEnabled: true,
})