Make project table associated with the user
This commit is contained in:
@@ -8,7 +8,7 @@ module.exports = function (sequelize) {
|
||||
|
||||
router.put('/:projectId', async (req, res) => {
|
||||
const projectId = req.params.projectId;
|
||||
const { name, detail } = req.body;
|
||||
const { name, detail, isPublic } = req.body;
|
||||
try {
|
||||
const project = await Project.findByPk(projectId);
|
||||
if (!project) {
|
||||
@@ -17,6 +17,7 @@ module.exports = function (sequelize) {
|
||||
await project.update({
|
||||
name,
|
||||
detail,
|
||||
isPublic,
|
||||
});
|
||||
res.json(project);
|
||||
} catch (error) {
|
||||
|
||||
@@ -8,10 +8,12 @@ module.exports = function (sequelize) {
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
try {
|
||||
const { name, detail } = req.body;
|
||||
const { name, detail, isPublic, userId } = req.body;
|
||||
const newProject = await Project.create({
|
||||
name,
|
||||
detail,
|
||||
isPublic,
|
||||
userId,
|
||||
});
|
||||
res.json(newProject);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user