Closed tiagopazhs closed 3 months ago
I used this following command to generate a migration:
npx sequelize-cli model:generate --name ActionTable --attributes name:string,description:string,initialDate:Date,status:string
not necessary to pass
id
as param, neithercreated_at
andupdated_at
.
File to test the model:
import ActionModel from './action.model';
async function testModel() {
try {
const newAction = await ActionModel.create({
name: 'Nome da Ação',
description: 'Descrição da Ação',
initialDate: new Date(),
status: 'ativo'
});
console.log('Action created with success:', newAction.toJSON());
} catch (error) {
console.error('Error to create the action:', error);
}
}
testModel();
File to test the task:
import TaskModel from './task.model';
async function testModel() {
try {
const newTask = await TaskModel.create({
name: 'nova',
status: 'ativo',
actionId: 3
});
console.log('Task created with success:', newTask.toJSON());
} catch (error) {
console.error('Error to create the task:', error);
}
}
testModel();
goal
expected results