-
Notifications
You must be signed in to change notification settings - Fork 22
Khalil Abdellah March 2 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cv-net
wants to merge
1
commit into
code-differently:main
Choose a base branch
from
cv-net:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,28 @@ | ||
| CREATE TABLE IF NOT EXISTS Pokemon ( | ||
| ID INT AUTO_INCREMENT, | ||
| Name VARCHAR(15), | ||
| PRIMARY KEY (ID) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS PokeTypes ( | ||
| ID INT AUTO_INCREMENT, | ||
| Type VARCHAR(15), | ||
| PRIMARY KEY (ID) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS PokeIndex ( | ||
| ID INT AUTO_INCREMENT, | ||
| PokemonID INT, | ||
| Type1 INT, | ||
| Type2 INT, | ||
| PRIMARY KEY (ID), | ||
| FOREIGN KEY (PokemonID) REFERENCES Pokemon(ID), | ||
| FOREIGN KEY (Type1) REFERENCES PokeTypes(ID), | ||
| FOREIGN KEY (Type2) REFERENCES PokeTypes(ID) | ||
| ); | ||
|
|
||
| SELECT * FROM PokeIndex; | ||
| SELECT * FROM PokeTypes; | ||
| SELECT * FROM Pokemon; | ||
|
|
||
| INSERT INTO PokeTypes VALUES (1, 'normal'), (2, 'fire'), (3, 'water'), (4, 'electric'), (5, 'grass'), (6, 'ice'), (7, 'fighting'), (8, 'poison'), (9, 'ground'), (10, 'flying'), (11, 'psychic'), (12, 'bug'), (13, 'rock'), (14, 'ghost'), (15, 'dragon'), (16, 'dark'), (17, 'steel'), (18, 'fairy'); | ||
This file contains hidden or 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,22 @@ | ||
| CREATE TABLE IF NOT EXISTS Pokemon ( | ||
| ID INT AUTO_INCREMENT, | ||
| Name VARCHAR(15), | ||
| PRIMARY KEY (ID) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS PokeTypes ( | ||
| ID INT AUTO_INCREMENT, | ||
| Type VARCHAR(15), | ||
| PRIMARY KEY (ID) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS PokeIndex ( | ||
| ID INT AUTO_INCREMENT, | ||
| PokemonID INT, | ||
| Type1 INT, | ||
| Type2 INT, | ||
| PRIMARY KEY (ID), | ||
| FOREIGN KEY (PokemonID) REFERENCES Pokemon(ID), | ||
| FOREIGN KEY (Type1) REFERENCES PokeTypes(ID), | ||
| FOREIGN KEY (Type2) REFERENCES PokeTypes(ID) | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove one of the two sql files, they both hold the same data |
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,11 +1,39 @@ | ||
| const express = require('express') | ||
| const app = express() | ||
| const port = 3000 | ||
| let mysql = require('mysql'); | ||
| let pass = ''; | ||
|
|
||
| app.get('/', (req, res) => { | ||
| res.send('Hello World!') | ||
| }) | ||
|
|
||
| app.listen(port, () => { | ||
| console.log(`Example app listening at http://localhost:${port}`) | ||
| }) | ||
| }) | ||
|
|
||
| app.get("/pokedex", async (req, res) => { | ||
| let pokedexData = await getPokedexData(); | ||
| res.send(pokedexData); | ||
| }) | ||
|
|
||
| async function getPokedexData() { | ||
|
|
||
| let conn = mysql.createConnection({ | ||
| host: "localhost", | ||
| user: "", | ||
| password: pass, | ||
| database: "pokedex" | ||
| }); | ||
|
|
||
| let data = new Promise((resolve, reject) => { | ||
| conn.query("SELECT * FROM Pokemon", (err, result, fields) => { | ||
| (err) ? reject(err) : resolve(result); | ||
| }) | ||
| }) | ||
|
|
||
| conn.end(); | ||
|
|
||
| return data; | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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,6 @@ | ||
| fetch("http://localhost:3000/pokedex") | ||
| .then(response => response.json()) | ||
| .then(console.log('success')) | ||
| // .then(customers => | ||
| // document.getElementById("customers").innerHTML = customers.map(customer => `<div>${pokedex.customerNumber}: ${customer.customername}</div>`).join("") | ||
| // ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally don't include insertion statements in the schema