File tree 3 files changed +69
-5
lines changed
3 files changed +69
-5
lines changed Original file line number Diff line number Diff line change 1
- const { where } = require ( 'sequelize/types' ) ;
2
- const type = require ( '../models/type' ) ;
3
1
const enginesRouter = require ( '../router/enginesRouter' ) ;
4
- const { types } = require ( './../models' )
2
+ const { type } = require ( './../models' )
5
3
6
4
class Types {
7
5
static getAll = async ( req , res , next ) => {
8
6
try {
9
- let data = await types . findAll ( )
7
+ let data = await type . findAll ( )
10
8
res . status ( 200 ) . json ( {
11
9
data
12
10
} )
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ const typeRouter = require('express').Router();
2
2
const typeController = require ( '../controllers/types' ) ;
3
3
const auth = require ( "../middlewares/auth" ) ;
4
4
5
- typeRouter . get ( '/types' , typeController . getAll )
5
+ typeRouter . get ( '/types' , typeController . getAll ) ;
6
+ typeRouter . get ( '/types/:id' , typeController . getDetail ) ;
7
+ typeRouter . post ( '/types' , typeController . postTypes ) ;
8
+ typeRouter . patch ( '/types/:id' , typeController . patchType ) ;
9
+ typeRouter . delete ( '/types/:id' , typeController . deleteType ) ;
6
10
7
11
module . exports = typeRouter ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ module . exports = {
4
+ up : async ( queryInterface , Sequelize ) => {
5
+ /**
6
+ * Add seed commands here.
7
+ *
8
+ * Example:
9
+ * await queryInterface.bulkInsert('People', [{
10
+ * name: 'John Doe',
11
+ * isBetaMember: false
12
+ * }], {});
13
+ */
14
+ await queryInterface . bulkInsert ( 'types' , [
15
+ {
16
+ name : 'Scooter' ,
17
+ foundedYear : 1915 ,
18
+ foundedCountry : 'Italy' ,
19
+ createdAt : new Date ( ) ,
20
+ updatedAt : new Date ( )
21
+ } ,
22
+ {
23
+ name : 'Sport' ,
24
+ foundedYear : 1894 ,
25
+ foundedCountry : 'France' ,
26
+ createdAt : new Date ( ) ,
27
+ updatedAt : new Date ( )
28
+ } ,
29
+ {
30
+ name : 'Adventure Tourer' ,
31
+ foundedYear : 1947 ,
32
+ foundedCountry : 'Spain' ,
33
+ createdAt : new Date ( ) ,
34
+ updatedAt : new Date ( )
35
+ } ,
36
+ {
37
+ name : 'Jetsky' ,
38
+ foundedYear : 1992 ,
39
+ foundedCountry : 'Japan' ,
40
+ createdAt : new Date ( ) ,
41
+ updatedAt : new Date ( )
42
+ } ,
43
+ {
44
+ name : 'Sport Tourer' ,
45
+ foundedYear : 1967 ,
46
+ foundedCountry : 'Northern Ireland' ,
47
+ createdAt : new Date ( ) ,
48
+ updatedAt : new Date ( )
49
+ }
50
+ ] )
51
+ } ,
52
+
53
+ down : async ( queryInterface , Sequelize ) => {
54
+ /**
55
+ * Add commands to revert seed here.
56
+ *
57
+ * Example:
58
+ * await queryInterface.bulkDelete('People', null, {});
59
+ */
60
+ await queryInterface . bulkDelete ( 'types' , null , { } ) ;
61
+ }
62
+ } ;
You can’t perform that action at this time.
0 commit comments