'Is it possible to update with PUT method using 'content', or 'number', these non-id attributes?
I try to update person's number in Node.js backend, with PUT method. Now, I succeeded with 'api/persons/:id', but if it possible to update using e.g., 'api/persons/:content'.
With the code below I get findByContentAndUpdate is not a function warning.
app.put('/api/persons/:content',(request, response, next)=>{
Person.findByContentAndUpdate({content:request.params.content}, request.body).then(function(){
console.log('request body', request.body)
Person.findOne({cotent:request.params.content}).then(function(person){
response.send(person)
})
})
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
