From 1e656f8c6d47b920fed0040616b1f7d905c2c70f Mon Sep 17 00:00:00 2001 From: elit04 <elit04@fu-berlin.de> Date: Sun, 9 Jan 2022 14:44:46 -0500 Subject: [PATCH] 'boatType' and 'tags' attributes added to Boat.ts (boatType will be needed for BoatType APIs) --- server/src/db/models/Boat.ts | 11 +++++++++++ server/src/db/seeder.ts | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/server/src/db/models/Boat.ts b/server/src/db/models/Boat.ts index 3692ce8..0227d35 100644 --- a/server/src/db/models/Boat.ts +++ b/server/src/db/models/Boat.ts @@ -3,9 +3,11 @@ import { Sequelize, DataTypes, Model, Optional } from "sequelize"; interface BoatAttributes { id: number; name: string; + boatType: string; status: boolean; active: boolean; seats: number; + tags: Array<string>; } export interface BoatAttributesInput extends Optional<BoatAttributes, "id"> { } @@ -13,9 +15,11 @@ export interface BoatAttributesOutput extends Required<BoatAttributes> { } class Boat extends Model<BoatAttributes> implements BoatAttributes { public id!: number; public name!: string; + public boatType: string; public status: boolean; public active: boolean; public seats: number; + public tags: Array<string>; public readonly createdAt!: Date; public readonly updatedAt!: Date; @@ -31,6 +35,10 @@ export const initBoat = async (sequelizeConnection: Sequelize) => { type: new DataTypes.STRING(), allowNull: false, }, + boatType: { + type: new DataTypes.STRING(), + allowNull: false, + }, status: { type: DataTypes.BOOLEAN, allowNull: false, @@ -43,6 +51,9 @@ export const initBoat = async (sequelizeConnection: Sequelize) => { type: new DataTypes.INTEGER(), allowNull: false, }, + tags: { + type: new DataTypes.ARRAY(DataTypes.STRING), + } }, { tableName: "boat", diff --git a/server/src/db/seeder.ts b/server/src/db/seeder.ts index df779ed..17dab6e 100644 --- a/server/src/db/seeder.ts +++ b/server/src/db/seeder.ts @@ -5,23 +5,29 @@ const seedBoatTable = async () => { await Boat.create({ id: 1, name: "boat one", + boatType: "canoe", status: false, active: true, seats: 5, + tags: ["big", "yellow"] }); await Boat.create({ id: 2, name: "boat two", + boatType: "kayak", status: false, active: true, seats: 4, + tags: ["red"] }); await Boat.create({ id: 3, name: "boat three", + boatType: "speedboat", status: false, active: false, seats: 2, + tags: ["dangerous", "fast"] }); } }; -- GitLab