0

Here is the request I am sending to create the record in MongoDB. StatusId datatype is an integer, but After create query DB has a string value of statusId. Don't know where I am going wrong. This is giving issue while retrieving the data from the static table. Please help me ??

  var requestData = {
         "requestId": data.requestId,
         "vendorId": data.vendorId,
         "date_assigned_start": new Date(),
         "date_assigned_end": null,
         "statusId": 1  //integer
     }
    ManageJobs.create(requestData ,(err,response) =>{
      if(err){
        cb(null,"DB error")
      }else{
        cb("Success")
   })

response:

"success": {
        "requestId": "5f8d6ea61c059118086ee6c0",
        "vendorId": "5ee63874c603e29e3ec470d0",
        "date_assigned_start": "2020-10-29T17:18:18.581Z",
        "date_assigned_end": null,
        "statusId": "1", //string
        "createdAt": "2020-10-29T17:18:18.585Z",
        "updatedAt": "2020-10-29T17:18:18.585Z",
        "id": "5f9af95a03de140d8cfd11f6"
    }
charu
  • 77
  • 9
  • 1
    Where are you logging your response from? If you are logging it from client side, it's pretty normal for all data to be converted to String during transmission (for ex, look at your date "objects"). Query your db to see if it is holding a string or an int. And if a string, check your ManageJobs model to make sure "statusId" is given the correct type in the definition. – arbuthnott Nov 03 '20 at 18:19
  • I`d also look at the model, first suspect you'd need to eliminate – Numant Santz Nov 04 '20 at 11:30

0 Answers0