[enh] The delete action should work
This commit is contained in:
parent
3ce2e4514d
commit
b0c6043741
3 changed files with 168 additions and 102 deletions
|
|
@ -54,6 +54,53 @@ const routes = {
|
|||
res.json({"health":0,"msg":"Lost connection to ES"});
|
||||
});
|
||||
},
|
||||
delete: (req,res) => {
|
||||
const id= req.params.id;
|
||||
// Reindex the doc to the "trash" index
|
||||
var log = client.reindex({
|
||||
refresh: true,
|
||||
max_docs: 1,
|
||||
body: {
|
||||
source: {
|
||||
index: 'changelog',
|
||||
query: {
|
||||
term: {
|
||||
_id: id
|
||||
}
|
||||
}
|
||||
},
|
||||
dest: {
|
||||
index: 'changelog-trash',
|
||||
}
|
||||
}
|
||||
})
|
||||
.then( (results, err) => {
|
||||
|
||||
console.log(`reindexing success for id ${id}`)
|
||||
// Remove it from the original index
|
||||
return client.delete({
|
||||
index: "changelog",
|
||||
id: id
|
||||
});
|
||||
|
||||
}, (e) => {
|
||||
|
||||
console.log("reindexing error")
|
||||
res.status(400);
|
||||
res.end("error");
|
||||
|
||||
})
|
||||
.then( (results, err) => {
|
||||
|
||||
console.log(`Delete success for id ${id}`)
|
||||
res.end("ok");
|
||||
|
||||
},(results, err) => {
|
||||
console.log(`Delete error for id ${id}`)
|
||||
res.status(400);
|
||||
res.end("error");
|
||||
});
|
||||
},
|
||||
add: (req, res) => {
|
||||
|
||||
const body = req.body;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue