Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function newDatabase() {
const adapter = new LokiJSAdapter({
schema,
});
const database = new Database({
actionsEnabled: true,
adapter,
// @ts-ignore
modelClasses: [Todo, User],
});
return database;
}
import serversSchema from './schema/servers';
import appSchema from './schema/app';
import migrations from './model/migrations';
import { isIOS } from '../../utils/deviceInfo';
const appGroupPath = isIOS ? `${ RNFetchBlob.fs.syncPathAppGroup('group.ios.chat.rocket') }/` : '';
if (__DEV__ && isIOS) {
console.log(appGroupPath);
}
class DB {
databases = {
serversDB: new Database({
adapter: new SQLiteAdapter({
dbName: `${ appGroupPath }default.db`,
schema: serversSchema
}),
modelClasses: [Server, User],
actionsEnabled: true
})
}
get active() {
return this.databases.activeDB;
}
get servers() {
return this.databases.serversDB;
}
setActiveDB(database = '') {
const path = database.replace(/(^\w+:|^)\/\//, '');
const dbName = `${ appGroupPath }${ path }.db`;
const adapter = new SQLiteAdapter({
dbName,
schema: appSchema,
migrations
});
this.databases.activeDB = new Database({
adapter,
modelClasses: [
Subscription,
Room,
Message,
Thread,
ThreadMessage,
CustomEmoji,
FrequentlyUsedEmoji,
Upload,
Setting,
Role,
Permission,
SlashCommand
],
actionsEnabled: true
import { Database } from '@nozbe/watermelondb'
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite'
import { mySchema } from './src/models/schema'
import Blog from './src/models/Blog'
import Post from './src/models/Post'
import Comment from './src/models/Comment'
import { createNavigation } from './src/components/helpers/Navigation'
const adapter = new SQLiteAdapter({
dbName: 'WatermelonDemo',
schema: mySchema,
})
const database = new Database({
adapter,
modelClasses: [Blog, Post, Comment],
actionsEnabled: true,
})
const appStartedLaunchingAt = NativeModules.PerformancePlugin.appInitTimestamp
const timeToLaunch = new Date().getTime() - appStartedLaunchingAt
const Navigation = createNavigation({ database, timeToLaunch })
AppRegistry.registerComponent('App', () => Navigation)
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,
})
export default database
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')
)