"error": "E_VALIDATION", "status": 400 node.js

477 views Asked by At

I am trying to save time entered by user in my database. But I am getting E_VALIDATION error 400. This is how I am trying to save it in my database

StopSchedule.create( timeObj ,function stopScheduleCreate (err,timeObj)
    {
        if(err){ 
            return next(err);
        }
        else
        {
            res.json(timeObj);
        }
    });

I have used console.log() to check the value of timeObj it shows

{ stopId: '1', routeId: '1', arivalTime: '12:02:10' }

This is exactly how I need it. If I send it with empty time filed it is saved successfully. Please guide me to solve this problem. Any help will be greatly appreciated.

Thanks

UPDATE: The model is as follows

module.exports = {
    schema      :true,
    tableName   :'stopschedule',
    connection  :'mysql-adapter',
    migrate     :'safe',
    autoCreatedAt: false,
    autoUpdatedAt: false,


    attributes: {

        stopId: {
            type: 'int',
        },

        routeId:{
            type: 'int',
        },

        arivalTime: {
            type:'time',
        },
    }
};
1

There are 1 answers

6
Aston On

It looks like the data format is wrong. What if you try with :

{ stopId: '1', routeId: '1' }

Can you give you model cofiguration ?