Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Updating document doesn't retrieve the ID #57

Open
HJassar opened this issue Mar 23, 2020 · 0 comments
Open

Updating document doesn't retrieve the ID #57

HJassar opened this issue Mar 23, 2020 · 0 comments

Comments

@HJassar
Copy link

HJassar commented Mar 23, 2020

Same issue here!
This issue doesn't happen when I create a document.

When I update a document, it does not add the ID of the document under "d"
example:

"_id": {
    "$oid": "5e79008e8ce8d721709619b9"
  },
  "t": {
    "$date": "2020-03-23T18:31:42.836Z"
  },
  "o": "u",
  "d": {
    "text": "<p>that is the question</p>"
  }
}

it should be

  "_id": {
    "$oid": "5e79008e8ce8d721709619b9"
  },
  "t": {
    "$date": "2020-03-23T18:31:42.836Z"
  },
  "o": "u",
  "d": {
"_id": { // ****** ID GOES HERE!! *****
      "$oid": "5e78fdbb445c0a13fc1fa193"
    },
    "text": "<p>that is the question</p>"
  }
}

This is the put route

    var id = req.params.id;
    var newData = req.body.post;
    Post.findByIdAndUpdate(id, newData, (err,post)=>{
        res.send(post.text);
    })
})

Thank you!

Originally posted by @IJassar in #47 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant