код контроллера
const { Street } = require('../models/models')
class StreetController {
async create(req, res) {
const newStreet = await Street.create({
street_name: req.body.street_name
});
return res.json(newStreet);
}
async getAllStreets(req, res) {
}
}
module.exports = new StreetController();
код streetRouter
const Router = require('express')
const router = new Router()
const streetController = require('../controllers/streetController')
router.post('/', streetController.create)
router.get('/', streetController.getAllStreets)
module.exports = router
ОБНОВЛЕНО
ошибка
ValidationError [SequelizeValidationError]: notNull Violation: street.description cannot be null
at InstanceValidator._validate (D:\programming\coursework\myguide\server\node_modules\sequelize\lib\instance-validator.js:50:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async InstanceValidator._validateAndRunHooks (D:\programming\coursework\myguide\server\node_modules\sequelize\lib\instance-validator.js:60:7)
at async InstanceValidator.validate (D:\programming\coursework\myguide\server\node_modules\sequelize\lib\instance-validator.js:54:12)
at async model.save (D:\programming\coursework\myguide\server\node_modules\sequelize\lib\model.js:2426:7)
at async street.create (D:\programming\coursework\myguide\server\node_modules\sequelize\lib\model.js:1362:12)
at async create (D:\programming\coursework\myguide\server\controllers\streetController.js:16:31) {
errors: [
ValidationErrorItem {
message: 'street.description cannot be null',
type: 'notNull Violation',
path: 'description',
value: null,
origin: 'CORE',
instance: [street],
validatorKey: 'is_null',
validatorName: null,
validatorArgs: []
}
]
}
дело в том, что я теперь добавляю description но всё равно ничего не получается