-
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.
Added MySQL backend & User Table (#54)
- Loading branch information
Kevin Gao
authored
Feb 14, 2020
1 parent
9f9e850
commit c802625
Showing
24 changed files
with
4,664 additions
and
4,058 deletions.
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
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,18 @@ | ||
{ | ||
"type": "mysql", | ||
"host": "code-reviewer-instance.chelhhbpfj3v.ca-central-1.rds.amazonaws.com", | ||
"port": 3306, | ||
"username": "admin", | ||
"password": "chickennuggets", | ||
"database": "code_reviewer", | ||
"synchronize": true, | ||
"logging": false, | ||
"entities": ["db/entity/**/*.ts"], | ||
"migrations": ["db/migration/**/*.ts"], | ||
"subscribers": ["db/subscriber/**/*.ts"], | ||
"cli": { | ||
"entitiesDir": "db/entity", | ||
"migrationsDir": "db/migration", | ||
"subscribersDir": "db/subscriber" | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,32 +1,37 @@ | ||
import { users } from '../mock-data' | ||
import { User } from '../../db/entity/User' | ||
|
||
export interface IGetUser { | ||
id?: String | ||
id?: number | ||
utorID?: String | ||
email?: String | ||
} | ||
|
||
// get one user based on id, utorID or email | ||
export const getUser = async (_: any, args: IGetUser) => { | ||
const resultUser = users.find(user => user.id === args.id) | ||
return resultUser | ||
try { | ||
const resultUser = await User.findOne(_, { where: args }) | ||
return resultUser | ||
} catch (e) { | ||
// TODO: Add Error management Urgent!! | ||
console.log(e) | ||
} | ||
} | ||
|
||
export interface IGetUsers { | ||
users: { | ||
id?: String | ||
id?: number | ||
firstName?: String | ||
lastName?: String | ||
utorID?: String | ||
email?: String | ||
userType?: String | ||
isActive?: Boolean | ||
isActive?: boolean | ||
} | ||
} | ||
|
||
// get 0 or more usrs based on the criterion | ||
// the criterion can be one or more properties from IGetUsers | ||
export const getUsers = async (_: any, args: IGetUsers) => { | ||
console.log(args) | ||
const users = await User.find({ where: args }) | ||
return users | ||
} |
Oops, something went wrong.