Creating a bike rent application and implementing addBike() to database. addCustomer() worked with this code, but I think it is because it has no foreign keys. How do I Insert Into database when half the table is foreign keys?
Thank you!
newbike.js:
add() {
bikeService.addBike(
this.wheelsize,
this.frame,
this.gears,
this.typeId,
this.location,
this.orderId,
id => {
history.push('/bike/' + id);
this.props.history.push('/regbike');
}
);
}
}
services.js:
connection.query(
'insert into Bike (wheelsize, frame, gears, typeId, statusId, location, orderId) values (?, ?, ?, ?, ?, ?, ?)',
[wheelsize, frame, gears, typeId, statusId, location, orderId],
(error, results) => {
if (error) return console.error(error);
success(results.insertId);
}
);
}
export let bikeService = new BikeService();