-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from DevKor-github/nativewind-model-schema
chore: setup_nativewind_setup_model_schema
- Loading branch information
Showing
20 changed files
with
1,277 additions
and
61 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,18 @@ | ||
import { appSchema, tableSchema } from "@nozbe/watermelondb"; | ||
import "reflect-metadata"; | ||
import { injectable } from "inversify"; | ||
|
||
export default appSchema({ | ||
version: 1, | ||
tables: [ | ||
tableSchema({ | ||
name: "posts", | ||
columns: [ | ||
{ name: "title", type: "string" }, | ||
{ name: "subtitle", type: "string", isOptional: true }, | ||
{ name: "body", type: "string" }, | ||
{ name: "is_pinned", type: "boolean" }, | ||
], | ||
}), | ||
], | ||
}); |
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
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
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,12 @@ | ||
import React from "react"; | ||
import { Text, TouchableOpacity } from "react-native"; | ||
|
||
const Test = () => { | ||
return ( | ||
<TouchableOpacity className="shadowneru"> | ||
<Text className="text-danger-400">TEST</Text> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
export default Test; |
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,39 @@ | ||
import { Platform } from "react-native"; | ||
import { Database } from "@nozbe/watermelondb"; | ||
import SQLiteAdapter from "@nozbe/watermelondb/adapters/sqlite"; | ||
|
||
import schema from "./schema"; | ||
import migrations from "./migrations"; | ||
|
||
import Schedule from "./models/Schedule"; | ||
import Place from "./models/Place"; | ||
import Preparation_schedule from "./models/Preparation_schedule"; | ||
import Preparation_user from "./models/Preparation_user"; | ||
import User from "./models/User"; | ||
|
||
export 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: [ | ||
Schedule, | ||
Place, | ||
Preparation_schedule, | ||
Preparation_user, | ||
User, | ||
], | ||
}); |
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,19 @@ | ||
import { Model } from "@nozbe/watermelondb"; | ||
import { field, text, relation } from '@nozbe/watermelondb/decorators'; | ||
|
||
|
||
class Place extends Model { | ||
static table = 'places' | ||
|
||
static associations = { | ||
schedules: { type: 'has_one', foreignKey: 'place_id' }, | ||
} | ||
|
||
@field("place_id") placeId; | ||
@text("place") place; | ||
|
||
@relation('places', 'place_id') place; | ||
|
||
} | ||
|
||
export default Place |
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 { Model } from "@nozbe/watermelondb"; | ||
import { field, text, relation } from '@nozbe/watermelondb/decorators'; | ||
|
||
|
||
class Preparation_schedule extends Model { | ||
static table = 'preparation_schedules' | ||
|
||
static associations = { | ||
schedules: { type: 'belongs_to', foreignKey: 'schedule_id' }, | ||
} | ||
|
||
@field("preparation_id") preparationId; | ||
@field("schedule_id") scheduleId; | ||
@text("perparation_name") preparationName; | ||
@field("preparation_time") preparationTime; | ||
@field("order") order; | ||
|
||
@relation('schedules', 'schedule_id') schedule; | ||
} | ||
|
||
export default Preparation_schedule |
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 { Model } from "@nozbe/watermelondb"; | ||
import { field, text, date, relation } from '@nozbe/watermelondb/decorators'; | ||
|
||
|
||
class Preparation_user extends Model { | ||
static table = 'preparation_users' | ||
|
||
static associations = { | ||
users: { type: 'belongs_to', foreignKey: 'user_id' }, | ||
} | ||
|
||
@field('preparation_id') preparationId; | ||
@field('user_id') userId; | ||
@text('preparation_name') preparationName; | ||
@field('preparation_time') preparationTime; | ||
@field('order') order; | ||
|
||
@relation('users', 'user_id') user; | ||
} | ||
|
||
export default Preparation_user |
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,30 @@ | ||
import { Model } from "@nozbe/watermelondb"; | ||
import { field, text, date, children, relation } from '@nozbe/watermelondb/decorators'; | ||
|
||
class Schedule extends Model { | ||
static table = 'schedules' | ||
|
||
static associations = { | ||
places: { type: 'belongs_to', foreignKey: 'place_id' }, | ||
users: { type: 'belongs_to', foreignKey: 'user_id' }, | ||
preparation_schedules: { type: 'has_many', foreignKey: 'schedule_id' }, | ||
|
||
} | ||
|
||
@field("schedule_id") scheduleId; | ||
@field("user_id") userId; | ||
@field("place_id") placeId; | ||
@date("schedule_time_at") scheduleTimeAt; | ||
@field("move_time") moveTime; | ||
@field("is_change") isChange; | ||
@field("is_started") isStarted; | ||
@field("schedule_spare_time") scheduleSpareTime; | ||
@text("schedule_note") scheduleNote; | ||
|
||
|
||
@relation('users', 'user_id') user; | ||
@relation('places', 'place_id') place; | ||
@children('preparation_schedules') preparation_schedules; | ||
} | ||
|
||
export default Schedule |
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,26 @@ | ||
import { Model } from "@nozbe/watermelondb"; | ||
import { field, text, children, relation } from '@nozbe/watermelondb/decorators'; | ||
|
||
|
||
class User extends Model { | ||
static table = 'users' | ||
|
||
static associations = { | ||
schedules: { type: 'has_many', foreignKey: 'user_id' }, | ||
preparation_users: { type: 'has_many', foreignKey: 'user_id' }, | ||
|
||
} | ||
|
||
@field("user_id") userId; | ||
@field("email") email; | ||
@field("password") password; | ||
@text("name") name; | ||
@field("spare_time") spareTime; | ||
@field("note") note; | ||
@field("score") score; | ||
|
||
@children('schedules') schedules; | ||
@children('preparation_users') preparation_users; | ||
} | ||
|
||
export default User |
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,83 @@ | ||
import { appSchema, tableSchema } from "@nozbe/watermelondb"; | ||
import "reflect-metadata"; | ||
import { injectable } from "inversify"; | ||
|
||
export default appSchema({ | ||
version: 1, | ||
tables: [ | ||
// Schedule table | ||
tableSchema({ | ||
name: "schedule", | ||
columns: [ | ||
{ name: "schedule_id", type: "number" }, | ||
{ name: "user_id", type: "number" }, | ||
{ name: "place_id", type: "number" }, | ||
// datetime | ||
{ name: "schedule_time_at", type: "number" }, | ||
// time | ||
{ name: "move_time", type: "number" }, | ||
{ name: "is_change", type: "boolean" }, | ||
{ name: "is_started", type: "boolean" }, | ||
// time | ||
{ name: "schedule_spare_time", type: "number" }, | ||
{ name: "schedule_note", type: "string" }, | ||
], | ||
}), | ||
// Place table | ||
tableSchema({ | ||
name: "place", | ||
columns: [ | ||
{ name: "place_id", type: "number" }, | ||
// varchar(30) | ||
{ name: "place", type: "string" }, | ||
], | ||
}), | ||
|
||
// Preparation_schedule | ||
tableSchema({ | ||
name: "preparation_schedule", | ||
columns: [ | ||
{ name: "preparation_id", type: "number" }, | ||
{ name: "schedule_id", type: "number" }, | ||
// varchar(30) | ||
{ name: "preparation_name", type: "string" }, | ||
// time | ||
{ name: "preparation_time", type: "number" }, | ||
{ name: "order", type: "number" }, | ||
], | ||
}), | ||
|
||
// User | ||
tableSchema({ | ||
name: "user", | ||
columns: [ | ||
{ name: "user_id", type: "number" }, | ||
// varchar(320) | ||
{ name: "email", type: "string" }, | ||
// varchar(30) | ||
{ name: "password", type: "string" }, | ||
// varchar(30) | ||
{ name: "name", type: "string" }, | ||
// time | ||
{ name: "spare_time", type: "number" }, | ||
{ name: "note", type: "string" }, | ||
// float | ||
{ name: "score", type: "number" }, | ||
], | ||
}), | ||
|
||
// Preparation_user | ||
tableSchema({ | ||
name: "preparation_user", | ||
columns: [ | ||
{ name: "preparation_id", type: "number" }, | ||
{ name: "user_id", type: "number" }, | ||
// varchar(30) | ||
{ name: "preparation_name", type: "string" }, | ||
// time | ||
{ name: "preparation_time", type: "number" }, | ||
{ name: "order", type: "number" }, | ||
], | ||
}), | ||
], | ||
}); |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
/// <reference types="nativewind/types" /> |
Oops, something went wrong.