forked from fga-eps-mds/2023-2-GEROcuidado-Front
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71c6dbf
commit abdd2b5
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Platform } from 'react-native' | ||
import { Database, tableSchema } from '@nozbe/watermelondb' | ||
import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite' | ||
|
||
import schema from './schema' | ||
import migrations from './migrations' | ||
import User from '../model/User' | ||
// import Post from './model/Post' // ⬅️ You'll import your Models here | ||
|
||
// First, create the adapter to the underlying database: | ||
const adapter = new SQLiteAdapter({ | ||
schema, | ||
// (You might want to comment it out for development purposes -- see Migrations documentation) | ||
migrations, | ||
// (optional database name or file system path) | ||
// dbName: 'myapp', | ||
// (recommended option, should work flawlessly out of the box on iOS. On Android, | ||
// additional installation steps have to be taken - disable if you run into issues...) | ||
jsi: true, /* Platform.OS === 'ios' */ | ||
// (optional, but you should implement this method) | ||
onSetUpError: error => { | ||
// Database failed to load -- offer the user to reload the app or log out | ||
} | ||
}) | ||
|
||
// Then, make a Watermelon database from it! | ||
const database = new Database({ | ||
adapter, | ||
modelClasses: [ | ||
// Post, // ⬅️ You'll add Models to Watermelon here | ||
User | ||
], | ||
}); | ||
|
||
export default database; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { schemaMigrations } from '@nozbe/watermelondb/Schema/migrations' | ||
|
||
export default schemaMigrations({ | ||
migrations: [ | ||
// We'll add migration definitions here later | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { appSchema, tableSchema } from '@nozbe/watermelondb' | ||
|
||
export default appSchema({ | ||
version: 1, | ||
tables: [ | ||
// We'll add tableSchemas here later | ||
tableSchema({ | ||
name: 'users', | ||
columns: [ | ||
{ name: 'external_id', type: 'string' }, | ||
{ name: 'name', type: 'string' }, | ||
{ name: 'email', type: 'string' }, | ||
{ name: 'photo', type: 'string' }, | ||
{ name: 'admin', type: 'boolean'}, | ||
{ name: 'password', type: 'string' }, | ||
{ name: 'created_at', type: 'number' }, | ||
{ name: 'updated_at', type: 'number' } | ||
] | ||
}) | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters