Skip to content

Instantly share code, notes, and snippets.

@zahqresh
Created July 19, 2021 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zahqresh/de53566244e72c607c3dd4e15a623141 to your computer and use it in GitHub Desktop.
Save zahqresh/de53566244e72c607c3dd4e15a623141 to your computer and use it in GitHub Desktop.
//Update one annotation
app.put('/api/annotations/:req_id', (req, res) => {
const {
qoute,
ranges,
text,
id
} = req.body;
const {
req_id
} = req.params;
let annotObj = {
"id": id,
"quote": qoute,
ranges: ranges,
text: text
};
db.findOneAndUpdate({ id: req_id }, {
rows: annotObj
}).then(doc => {
res.json(annotObj);
})
})
//Delete one annotation
app.delete('/api/annotations/:req_id', (req, res) => {
const {
req_id
} = req.params;
db.findOneAndDelete({ id: req_id }).then(() => {
res.json(req.body);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment