Start moving data server handling from pinia store to server
This commit is contained in:
@@ -12,40 +12,35 @@
|
||||
"date": "2024-10-18",
|
||||
"price": 92,
|
||||
"inStock": 0,
|
||||
"locationId": 0,
|
||||
"tourId": 0
|
||||
"locationId": 0
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"date": "2024-10-19",
|
||||
"price": 92,
|
||||
"inStock": 170,
|
||||
"locationId": 0,
|
||||
"tourId": 0
|
||||
"locationId": 0
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"date": "2024-10-23",
|
||||
"price": 119.90,
|
||||
"inStock": 8736,
|
||||
"locationId": 4,
|
||||
"tourId": 0
|
||||
"locationId": 4
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"date": "2024-10-26",
|
||||
"price": 114.90,
|
||||
"inStock": 2793,
|
||||
"locationId": 8,
|
||||
"tourId": 0
|
||||
"locationId": 8
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"date": "2024-11-02",
|
||||
"price": 124.90,
|
||||
"inStock": 3079,
|
||||
"locationId": 12,
|
||||
"tourId": 0
|
||||
"locationId": 12
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -61,24 +56,21 @@
|
||||
"date": "2024-11-30",
|
||||
"price": 108,
|
||||
"inStock": 1200,
|
||||
"locationId": 1,
|
||||
"tourId": 1
|
||||
"locationId": 1
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"date": "2024-12-01",
|
||||
"price": 104,
|
||||
"inStock": 1800,
|
||||
"locationId": 5,
|
||||
"tourId": 1
|
||||
"locationId": 5
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"date": "2024-12-07",
|
||||
"price": 99.90,
|
||||
"inStock": 2438,
|
||||
"locationId": 9,
|
||||
"tourId": 1
|
||||
"locationId": 9
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -94,16 +86,14 @@
|
||||
"date": "2025-01-21",
|
||||
"price": 67.90,
|
||||
"inStock": 994,
|
||||
"locationId": 3,
|
||||
"tourId": 2
|
||||
"locationId": 3
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"date": "2024-11-15",
|
||||
"price": 79.90,
|
||||
"inStock": 1073,
|
||||
"locationId": 14,
|
||||
"tourId": 2
|
||||
"locationId": 14
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -119,24 +109,21 @@
|
||||
"date": "2024-12-07",
|
||||
"price": 124.90,
|
||||
"inStock": 765,
|
||||
"locationId": 13,
|
||||
"tourId": 3
|
||||
"locationId": 13
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"date": "2025-01-17",
|
||||
"price": 129.90,
|
||||
"inStock": 989,
|
||||
"locationId": 9,
|
||||
"tourId": 3
|
||||
"locationId": 9
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"date": "2025-02-01",
|
||||
"price": 134.90,
|
||||
"inStock": 827,
|
||||
"locationId": 4,
|
||||
"tourId": 3
|
||||
"locationId": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -152,8 +139,7 @@
|
||||
"date": "2024-12-05",
|
||||
"price": 80,
|
||||
"inStock": 99,
|
||||
"locationId": 2,
|
||||
"tourId": 4
|
||||
"locationId": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -169,16 +155,14 @@
|
||||
"date": "2025-01-12",
|
||||
"price": 81.90,
|
||||
"inStock": 173,
|
||||
"locationId": 2,
|
||||
"tourId": 5
|
||||
"locationId": 2
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"date": "2025-02-01",
|
||||
"price": 84.90,
|
||||
"inStock": 192,
|
||||
"locationId": 6,
|
||||
"tourId": 5
|
||||
"locationId": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -194,16 +178,14 @@
|
||||
"date": "2025-02-27",
|
||||
"price": 67.90,
|
||||
"inStock": 847,
|
||||
"locationId": 3,
|
||||
"tourId": 6
|
||||
"locationId": 3
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"date": "2025-03-06",
|
||||
"price": 64.90,
|
||||
"inStock": 245,
|
||||
"locationId": 9,
|
||||
"tourId": 6
|
||||
"locationId": 9
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -219,32 +201,28 @@
|
||||
"date": "2025-01-15",
|
||||
"price": 67.90,
|
||||
"inStock": 847,
|
||||
"locationId": 2,
|
||||
"tourId": 7
|
||||
"locationId": 2
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"date": "2025-01-23",
|
||||
"price": 64.90,
|
||||
"inStock": 245,
|
||||
"locationId": 10,
|
||||
"tourId": 7
|
||||
"locationId": 10
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"date": "2025-02-02",
|
||||
"price": 64.90,
|
||||
"inStock": 245,
|
||||
"locationId": 13,
|
||||
"tourId": 7
|
||||
"locationId": 13
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"date": "2025-02-05",
|
||||
"price": 64.90,
|
||||
"inStock": 245,
|
||||
"locationId": 13,
|
||||
"tourId": 7
|
||||
"locationId": 13
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": 0,
|
||||
"orderId": 0,
|
||||
"showId": 0,
|
||||
"quantity": 2,
|
||||
"orderPrice": 184
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,21 +5,43 @@
|
||||
"accountId": 0,
|
||||
"shippingProgress": 4,
|
||||
"addressId": 0,
|
||||
"paymentId": 0
|
||||
"paymentId": 0,
|
||||
"tickets": [
|
||||
{
|
||||
"concertId": 0,
|
||||
"orderPrice": 184
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"accountId": 3,
|
||||
"shippingProgress": 5,
|
||||
"addressId": 4,
|
||||
"paymentId": 3
|
||||
"paymentId": 3,
|
||||
"tickets": [
|
||||
{
|
||||
"concertId": 0,
|
||||
"orderPrice": 184
|
||||
},
|
||||
{
|
||||
"concertId": 0,
|
||||
"orderPrice": 184
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"accountId": 3,
|
||||
"shippingProgress": 2,
|
||||
"addressId": 5,
|
||||
"paymentId": 3
|
||||
"paymentId": 3,
|
||||
"tickets": [
|
||||
{
|
||||
"concertId": 0,
|
||||
"orderPrice": 184
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { Sequelize } from "sequelize-typescript"
|
||||
|
||||
// Models
|
||||
import { Order } from "./models/ordering/order.model"
|
||||
import { OrderItem } from "./models/ordering/orderItem.model"
|
||||
import { Ticket } from "./models/ordering/ticket.model"
|
||||
import { Account } from "./models/user/account.model"
|
||||
import { prepopulateDatabase } from "./scripts/databaseHelper"
|
||||
import { Address } from "./models/user/address.model"
|
||||
@@ -14,7 +14,7 @@ import { Band } from "./models/acts/band.model"
|
||||
import { Concert } from "./models/acts/concert.model"
|
||||
import { Member } from "./models/acts/member.model"
|
||||
import { Rating } from "./models/acts/rating.model"
|
||||
import { Tour } from "./models/acts/tour.model"
|
||||
import { Event } from "./models/acts/event.model"
|
||||
import { City } from "./models/locations/city.model"
|
||||
import { BandGenre } from "./models/acts/bandGenre.model"
|
||||
import { Seat } from "./models/locations/seat.model"
|
||||
@@ -35,18 +35,23 @@ export const sequelize = new Sequelize({
|
||||
models: [
|
||||
AccountRole, Account, Payment, Address,
|
||||
City, Location, SeatGroup, SeatRow, Seat,
|
||||
Genre, Band, BandGenre, Rating, Member, Tour, Concert,
|
||||
Order, OrderItem
|
||||
Genre, Band, BandGenre, Rating, Member, Event, Concert,
|
||||
Order, Ticket
|
||||
]
|
||||
})
|
||||
|
||||
export function startDatabase() {
|
||||
let force = false
|
||||
|
||||
// Create database and tables
|
||||
sequelize.sync({ force: true })
|
||||
sequelize.sync({ force: force })
|
||||
.then(() => {
|
||||
console.log("Database & tables created!")
|
||||
|
||||
prepopulateDatabase()
|
||||
if (force) {
|
||||
prepopulateDatabase()
|
||||
}
|
||||
|
||||
console.log("Database prepopulated!")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { BelongsTo, BelongsToMany, Column, DataType, ForeignKey, HasMany, Model,
|
||||
import { Member } from "./member.model";
|
||||
import { Genre } from "./genre.model";
|
||||
import { Rating } from "./rating.model";
|
||||
import { Tour } from "./tour.model";
|
||||
import { Event } from "./event.model";
|
||||
import { BandGenre } from "./bandGenre.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
@@ -45,8 +45,8 @@ export class Band extends Model {
|
||||
@HasMany(() => Rating)
|
||||
ratings: Rating[]
|
||||
|
||||
@HasMany(() => Tour)
|
||||
tours: Tour[]
|
||||
@HasMany(() => Event)
|
||||
events: Event[]
|
||||
|
||||
@BelongsToMany(() => Genre, () => BandGenre)
|
||||
genres: Genre[]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BelongsTo, Column, ForeignKey, HasMany, Model, Table } from "sequelize-typescript";
|
||||
import { Location } from "./../locations/location.model";
|
||||
import { Tour } from "./tour.model";
|
||||
import { OrderItem } from "../ordering/orderItem.model";
|
||||
import { Event } from "./event.model";
|
||||
import { Ticket } from "../ordering/ticket.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Concert extends Model {
|
||||
@@ -18,18 +18,19 @@ export class Concert extends Model {
|
||||
@Column
|
||||
locationId: Number
|
||||
|
||||
@ForeignKey(() => Tour)
|
||||
tourId: Number
|
||||
@ForeignKey(() => Event)
|
||||
@Column
|
||||
eventId: Number
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsTo(() => Tour)
|
||||
tour: Tour
|
||||
@BelongsTo(() => Event)
|
||||
event: Event
|
||||
|
||||
@BelongsTo(() => Location)
|
||||
location: Location
|
||||
|
||||
@HasMany(() => OrderItem)
|
||||
orderItems: OrderItem[]
|
||||
@HasMany(() => Ticket)
|
||||
tickets: Ticket[]
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { Band } from "./band.model";
|
||||
import { Concert } from "./concert.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Tour extends Model {
|
||||
export class Event extends Model {
|
||||
@Column
|
||||
name: String
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Table, Column, Model, BelongsTo, ForeignKey, HasMany, BelongsToMany, Default } from 'sequelize-typescript';
|
||||
import { Account } from '../user/account.model';
|
||||
import { OrderItem } from './orderItem.model';
|
||||
import { Ticket } from './ticket.model';
|
||||
import { Address } from '../user/address.model';
|
||||
import { Payment } from '../user/payment.model';
|
||||
|
||||
@@ -40,6 +40,6 @@ export class Order extends Model {
|
||||
@BelongsTo(() => Payment)
|
||||
payment: Payment
|
||||
|
||||
@HasMany(() => OrderItem)
|
||||
orderItems: OrderItem[]
|
||||
@HasMany(() => Ticket)
|
||||
tickets: Ticket[]
|
||||
}
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
import { Model, BelongsTo, Column, ForeignKey, HasMany, HasOne, Table } from "sequelize-typescript";
|
||||
import { Concert } from "../acts/concert.model";
|
||||
import { Order } from "./order.model";
|
||||
import { Seat } from "../locations/seat.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class OrderItem extends Model {
|
||||
export class Ticket extends Model {
|
||||
@Column
|
||||
@ForeignKey(() => Order)
|
||||
orderId: number
|
||||
|
||||
@Column
|
||||
quantity: number
|
||||
|
||||
@Column
|
||||
orderPrice: number
|
||||
|
||||
@Column
|
||||
@ForeignKey(() => Concert)
|
||||
showId: number
|
||||
concertId: number
|
||||
|
||||
@Column
|
||||
@ForeignKey(() => Seat)
|
||||
seatId: number
|
||||
|
||||
|
||||
// Relations
|
||||
@@ -25,4 +27,7 @@ export class OrderItem extends Model {
|
||||
|
||||
@BelongsTo(() => Concert)
|
||||
product: Concert
|
||||
|
||||
@BelongsTo(() => Seat)
|
||||
seat: Seat
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { Band } from "../models/acts/band.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Rating } from "../models/acts/rating.model";
|
||||
import { Genre } from "../models/acts/genre.model";
|
||||
import { Tour } from "../models/acts/tour.model";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
@@ -27,7 +27,7 @@ band.get("/", (req: Request, res: Response) => {
|
||||
}
|
||||
},
|
||||
{
|
||||
model: Tour,
|
||||
model: Event,
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Tour } from "../models/acts/tour.model";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
|
||||
export const concert = Router()
|
||||
@@ -9,7 +9,7 @@ export const concert = Router()
|
||||
concert.get("/:id", (req: Request, res: Response) => {
|
||||
Concert.findByPk(req.params.id, {
|
||||
include: [
|
||||
Tour,
|
||||
Event,
|
||||
{
|
||||
model: Location,
|
||||
include: [ City ],
|
||||
|
||||
79
software/backend/routes/events.routes.ts
Normal file
79
software/backend/routes/events.routes.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Genre } from "../models/acts/genre.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
|
||||
export const events = Router()
|
||||
|
||||
events.get("/", async (req: Request, res: Response) => {
|
||||
let cityName = req.query.city
|
||||
let genreName = req.query.genre
|
||||
let cityFilter = {}
|
||||
let genreFilter = {}
|
||||
|
||||
if (cityName != undefined) {
|
||||
cityFilter = {
|
||||
model: City,
|
||||
where: { name: cityName }
|
||||
}
|
||||
} else {
|
||||
cityFilter = {
|
||||
model: City
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (genreName != undefined) {
|
||||
genreFilter = {
|
||||
model: Genre,
|
||||
where: { name: genreName }
|
||||
}
|
||||
} else {
|
||||
genreFilter = {
|
||||
model: Genre
|
||||
}
|
||||
}
|
||||
|
||||
Event.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
include: [
|
||||
cityFilter
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
model: Band,
|
||||
include: [
|
||||
genreFilter
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(events => {
|
||||
let resultArray = []
|
||||
|
||||
// Remove datasets which not fulfill the optional parameter
|
||||
for (let event of events) {
|
||||
if (event.dataValues.band != null) {
|
||||
for (let concert of event.dataValues.concerts) {
|
||||
if (concert.dataValues.location != null) {
|
||||
resultArray.push(event)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.status(200).json(resultArray)
|
||||
})
|
||||
|
||||
})
|
||||
@@ -2,7 +2,7 @@ import { Concert } from "../models/acts/concert.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Tour } from "../models/acts/tour.model";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { SeatGroup } from "../models/locations/seatGroup.model";
|
||||
import { Seat } from "../models/locations/seat.model";
|
||||
@@ -16,7 +16,7 @@ location.get("/", (req: Request, res: Response) => {
|
||||
City,
|
||||
{
|
||||
model: Concert,
|
||||
include: [ Tour ],
|
||||
include: [ Event ],
|
||||
attributes: {
|
||||
exclude: [ "locationId", "tourId" ]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { Order } from "../models/ordering/order.model";
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { OrderItem } from "../models/ordering/orderItem.model";
|
||||
import { Ticket } from "../models/ordering/ticket.model";
|
||||
import { Payment } from "../models/user/payment.model";
|
||||
import { Address } from "../models/user/address.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
@@ -15,7 +15,7 @@ order.get("/:id", (req: Request, res: Response) => {
|
||||
where: { accountId: req.params.id },
|
||||
include: [
|
||||
{
|
||||
model: OrderItem,
|
||||
model: Ticket,
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
@@ -43,7 +43,7 @@ order.post("/", (req: Request, res: Response) => {
|
||||
Order.create(req.body)
|
||||
.then(async order => {
|
||||
for (let orderItem of req.body.orderItems) {
|
||||
OrderItem.create({
|
||||
Ticket.create({
|
||||
orderId: order.id,
|
||||
quantity: orderItem.quantity,
|
||||
orderPrice: orderItem.orderPrice,
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { Tour } from "../models/acts/tour.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Genre } from "../models/acts/genre.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
|
||||
export const tour = Router()
|
||||
|
||||
tour.get("/", (req: Request, res: Response) => {
|
||||
Tour.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Band,
|
||||
include: [ Genre ],
|
||||
attributes: {
|
||||
exclude: [ "genreId" ]
|
||||
}
|
||||
},
|
||||
{
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
include: [ City ],
|
||||
attributes: {
|
||||
exclude: [ "cityId" ]
|
||||
}
|
||||
}
|
||||
],
|
||||
attributes: {
|
||||
exclude: [ "locationId", "tourId" ]
|
||||
}
|
||||
},
|
||||
],
|
||||
attributes: {
|
||||
exclude: [ "bandId" ]
|
||||
}
|
||||
})
|
||||
.then(tours => {
|
||||
res.status(200).json(tours)
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Order } from '../models/ordering/order.model'
|
||||
import { OrderItem } from '../models/ordering/orderItem.model'
|
||||
import { Ticket } from '../models/ordering/ticket.model'
|
||||
import { Account } from '../models/user/account.model'
|
||||
import { Address } from '../models/user/address.model'
|
||||
import { Payment } from '../models/user/payment.model'
|
||||
@@ -10,7 +10,7 @@ import { Genre } from '../models/acts/genre.model'
|
||||
import { Band } from '../models/acts/band.model'
|
||||
import { Location } from '../models/locations/location.model'
|
||||
import { Concert } from '../models/acts/concert.model'
|
||||
import { Tour } from '../models/acts/tour.model'
|
||||
import { Event } from '../models/acts/event.model'
|
||||
import { City } from '../models/locations/city.model'
|
||||
import { BandGenre } from '../models/acts/bandGenre.model'
|
||||
import { SeatGroup } from '../models/locations/seatGroup.model'
|
||||
@@ -19,11 +19,10 @@ import { SeatRow } from '../models/locations/seatRow.model'
|
||||
|
||||
import accounts from "./../data/accounts.json"
|
||||
import orders from "./../data/orders.json"
|
||||
import orderItems from "./../data/orderItems.json"
|
||||
import accountRoles from "./../data/accountRoles.json"
|
||||
import bands from "./../data/bands.json"
|
||||
import genres from "./../data/genres.json"
|
||||
import tours from "./../data/tours.json"
|
||||
import events from "./../data/events.json"
|
||||
import cities from "./../data/cities.json"
|
||||
|
||||
|
||||
@@ -31,14 +30,14 @@ import cities from "./../data/cities.json"
|
||||
* Delete all datasets in every database table
|
||||
*/
|
||||
export function deleteAllTables() {
|
||||
OrderItem.destroy({truncate: true })
|
||||
Ticket.destroy({truncate: true })
|
||||
Order.destroy({ truncate: true })
|
||||
|
||||
Rating.destroy({ truncate: true })
|
||||
Member.destroy({ truncate: true })
|
||||
Genre.destroy({ truncate: true })
|
||||
Band.destroy({ truncate: true })
|
||||
Tour.destroy({ truncate: true })
|
||||
Event.destroy({ truncate: true })
|
||||
|
||||
Location.destroy({ truncate: true })
|
||||
Concert.destroy({ truncate: true })
|
||||
@@ -145,15 +144,25 @@ export async function prepopulateDatabase() {
|
||||
}
|
||||
|
||||
|
||||
for (let tour of tours.data) {
|
||||
await Tour.create(tour)
|
||||
for (let tour of events.data) {
|
||||
await Event.create(tour)
|
||||
.then(async dataset => {
|
||||
for (let concert of tour.concerts) {
|
||||
concert["eventId"] = dataset.id
|
||||
|
||||
await Concert.create(concert)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Order.bulkCreate(orders.data)
|
||||
OrderItem.bulkCreate(orderItems.data)
|
||||
for (let order of orders.data) {
|
||||
await Order.create(order)
|
||||
.then(async dataset => {
|
||||
for (let ticket of order.tickets) {
|
||||
ticket["orderId"] = dataset.id
|
||||
|
||||
await Ticket.create(ticket)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import { concert } from './routes/concert.routes'
|
||||
import { band } from './routes/band.routes'
|
||||
import { genre } from './routes/genre.routes'
|
||||
import { location } from './routes/location.routes'
|
||||
import { tour } from './routes/tour.routes'
|
||||
import { events } from './routes/events.routes'
|
||||
import { city } from './routes/city.routes'
|
||||
|
||||
const app = express()
|
||||
@@ -35,13 +35,12 @@ app.use('/static', express.static(path.join(__dirname, 'images')))
|
||||
|
||||
// Routes
|
||||
app.use("/api", api)
|
||||
app.use("/shows", concert)
|
||||
app.use("/events", events)
|
||||
app.use("/bands", band)
|
||||
app.use("/genres", genre)
|
||||
app.use("/locations", location)
|
||||
app.use("/genres", genre)
|
||||
app.use("/orders", order)
|
||||
app.use("/accounts", account)
|
||||
app.use("/tours", tour)
|
||||
app.use("/cities", city)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user