Skip to content

Commit 1d0b8e5

Browse files
authored
Merge pull request #7 from leachcoding/jay-leach
Final bug fixes for now -- starting on machines
2 parents 8ef1da3 + 6a31e24 commit 1d0b8e5

File tree

10 files changed

+122
-118
lines changed

10 files changed

+122
-118
lines changed

03-machines.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// exports.seed = function (knex) {
2+
// return knex('').truncate()
3+
// .then(function () {
4+
// return knex('').insert([
5+
// {
6+
// name: 'tm01',
7+
// pokeid: 2,
8+
// user_id: 1,
9+
// count: 1,
10+
// move: 'mega-punch'
11+
// }
12+
// ]);
13+
// });
14+
// };

04-berries.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// exports.seed = function (knex) {
2+
// return knex('').truncate()
3+
// .then(function () {
4+
// return knex('').insert([
5+
// {
6+
// name: 'chesto',
7+
// pokeid: 2,
8+
// user_id: 1,
9+
// size: 80,
10+
// smoothness: 25,
11+
// naturalGiftPower: 60,
12+
// soilDryness: 15,
13+
// growthTime: 3,
14+
// maxHarvest: 5
15+
// }
16+
// ]);
17+
// });
18+
// };

05-pokemon.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// exports.seed = function (knex) {
2+
// return knex('').truncate()
3+
// .then(function () {
4+
// return knex('').insert([
5+
// {
6+
// pokeid: 1,
7+
// name: 'bulbasaur',
8+
// img: 'https://img.pokemondb.net/sprites/black-white/anim/normal/bulbasaur.gif',
9+
// height: 7,
10+
// weight: 69,
11+
// types: ['poison', 'grass'],
12+
// speed: 45,
13+
// specialAttack: 65,
14+
// specialDefense: 65,
15+
// defense: 45,
16+
// attack: 49,
17+
// hp: 45,
18+
// abilities: ['chlorophyll', 'overgrow'],
19+
// moves: ['razor-wind', 'swords-dance', 'cut', 'bind'],
20+
// user_id: 1
21+
// }
22+
// ]);
23+
// });
24+
// };

database/auth.db3

16 KB
Binary file not shown.

database/migrations/20200305182952_create_tables.js

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,79 @@ exports.up = function(knex) {
77
})
88

99
.createTable('items', tbl => {
10+
tbl.increments();
1011
tbl.string('name').notNullable();
11-
tbl.integer('id');
12-
tbl.integer('cost');
12+
tbl.integer('pokeid');
13+
tbl.integer('costAmount');
1314
tbl.integer('user_id')
1415
.unsigned()
1516
.notNullable()
16-
references('id')
17+
.references('pokeid')
1718
.inTable('users')
1819
.onUpdate('CASCADE')
1920
.onDelete('RESTRICT');
2021
tbl.integer('total_count');
2122
tbl.integer('count').defaultTo(0);
2223
})
2324

24-
.createTable('machines', tbl => {
25-
tbl.string('name').notNullable();
26-
tbl.integer('id');
27-
tbl.integer('user_id')
28-
.unsigned()
29-
.notNullable()
30-
references('id')
31-
.inTable('users')
32-
.onUpdate('CASCADE')
33-
.onDelete('RESTRICT');
34-
tbl.integer('count').defaultTo(0);
35-
tbl.string('mega-punch').notNullable();
36-
})
37-
38-
.createTable('berries', tbl => {
39-
tbl.string('name').notNullable();
40-
tbl.integer('id');
41-
tbl.integer('user_id')
42-
.unsigned()
43-
.notNullable()
44-
references('id')
45-
.inTable('users')
46-
.onUpdate('CASCADE')
47-
.onDelete('RESTRICT');
48-
tbl.integer('size');
49-
tbl.integer('smoothness');
50-
tbl.integer('naturalGiftPower');
51-
tbl.integer('soilDryness');
52-
tbl.integer('growthTime');
53-
tbl.integer('maxHarvest');
54-
})
55-
56-
.createTable('pokemon', tbl => {
57-
tbl.integer('id');
58-
tbl.string('name').notNullable();
59-
tbl.string('img').notNullable();
60-
tbl.integer('height');
61-
tbl.integer('weight');
62-
tbl.specificType('types', 'text ARRAY');
63-
tbl.integer('speed');
64-
tbl.integer('specialAttack');
65-
tbl.integer('specialDefense');
66-
tbl.integer('defense');
67-
tbl.integer('attack');
68-
tbl.integer('hp');
69-
tbl.specificType('abilities', 'text ARRAY');
70-
tbl.specificType('moves', 'text ARRAY');
71-
tbl.integer('user_id')
72-
.unsigned()
73-
.notNullable()
74-
references('id')
75-
.inTable('users')
76-
.onUpdate('CASCADE')
77-
.onDelete('RESTRICT');
78-
})
25+
// .createTable('machines', tbl => {
26+
// tbl.increments();
27+
// tbl.string('name').notNullable();
28+
// tbl.integer('pokeid');
29+
// tbl.integer('user_id')
30+
// .unsigned()
31+
// .notNullable()
32+
// .references('pokeid')
33+
// .inTable('users')
34+
// .onUpdate('CASCADE')
35+
// .onDelete('RESTRICT');
36+
// tbl.integer('count').defaultTo(0);
37+
// tbl.string('mega-punch').notNullable();
38+
// })
39+
//
40+
// .createTable('berries', tbl => {
41+
// tbl.increments();
42+
// tbl.string('name').notNullable();
43+
// tbl.integer('pokeid');
44+
// tbl.integer('user_id')
45+
// .unsigned()
46+
// .notNullable()
47+
// .references('pokeid')
48+
// .inTable('users')
49+
// .onUpdate('CASCADE')
50+
// .onDelete('RESTRICT');
51+
// tbl.integer('size');
52+
// tbl.integer('smoothness');
53+
// tbl.integer('naturalGiftPower');
54+
// tbl.integer('soilDryness');
55+
// tbl.integer('growthTime');
56+
// tbl.integer('maxHarvest');
57+
// })
58+
//
59+
// .createTable('pokemon', tbl => {
60+
// tbl.increments();
61+
// tbl.integer('pokeid');
62+
// tbl.string('name').notNullable();
63+
// tbl.string('img').notNullable();
64+
// tbl.integer('height');
65+
// tbl.integer('weight');
66+
// tbl.specificType('types', 'text ARRAY');
67+
// tbl.integer('speed');
68+
// tbl.integer('specialAttack');
69+
// tbl.integer('specialDefense');
70+
// tbl.integer('defense');
71+
// tbl.integer('attack');
72+
// tbl.integer('hp');
73+
// tbl.specificType('abilities', 'text ARRAY');
74+
// tbl.specificType('moves', 'text ARRAY');
75+
// tbl.integer('user_id')
76+
// .unsigned()
77+
// .notNullable()
78+
// .references('pokeid')
79+
// .inTable('users')
80+
// .onUpdate('CASCADE')
81+
// .onDelete('RESTRICT');
82+
// })
7983
};
8084

8185
exports.down = function(knex) {

database/seeds/02-items.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ exports.seed = function (knex) {
44
return knex('items').insert([
55
{
66
name: 'timer-ball',
7-
id: 10,
8-
cost: 1000,
7+
pokeid: 10,
8+
costAmount: 1000,
99
user_id: 1,
10-
total_count: cost * count,
10+
total_count: 2000,
1111
count: 2
1212
}
1313
]);

database/seeds/03-machines.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

database/seeds/04-berries.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

database/seeds/05-pokemon.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

items/itemRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async function validateUser(req, res, next) {
121121
? res.status(404).json({ message: "User does not exist!" })
122122
: !item ?
123123
res.status(404).json({ message: "Item does not exist!" })
124-
: !item.name || !item.id || !item.cost || !item.total_count
124+
: !item.name || !item.id || !item.costAmount || !item.total_count
125125
? res.status(406).json({ message: "Please make sure the required fields are completed. " })
126126
: next();
127127
}

0 commit comments

Comments
 (0)