-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
36 lines (30 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import {Platform} from 'react-native';
import {Database} from '@nozbe/watermelondb';
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite';
import schema from './src/model/schema';
import migrations from './src/model/migration';
import {Post} from './src/model/Post.model';
import {Blog} from './src/model/Blog.model';
import {Comment} from './src/model/Comment.model';
// import Post from './model/Post' // ⬅️ You'll import your Models here
// First, create the adapter to the underlying database:
const adapter = new SQLiteAdapter({
schema,
migrations,
onSetUpError: error => {
console.log('here');
// Database failed to load -- offer the user to reload the app or log out
},
});
// Then, make a Watermelon database from it!
export const database = new Database({
adapter,
modelClasses: [Blog, Post, Comment],
});
AppRegistry.registerComponent(appName, () => App);