deleteJson mutation usage
Dgraph Version
``` v20.11.1 ```What I want to do
I’m doing a small todo app in Vue using Dgraph to test the tech, and while I can add or edit my nodes using the setJson
mutation, I can’t delete my nodes with deleteJson
What I did
Here’s my add and my delete methods:
AddTodo()
(working )
async addTodo(title = this.title) {
try {
const res = await this.dgraph.newTxn().mutate({
setJson: {
uid: "_:newTodo",
is_todo: true,
title,
completed: false
},
commitNow: true
});
} catch (error) {
alert("Database write failed!");
console.error("Network error", error);
} finally {
this.title = "";
this.fetchData();
}
},
DeleteTodo(todo)
(not working: )
async DeleteTodo(todo) {
try {
await this.dgraph.newTxn().mutate({
deleteJson: {
uid: todo.uid
},
commitNow: true
});
} catch (error) {
alert("Database write failed!");
console.error("Network error", error);
} finally {
this.fetchData();
}
},
I also tried directly in Ratel but without success.
The thing is if I add a console.log() in the finally
state of the promise it actually shows up, but my todos are still complete, the node I asked to delete is here too.
What am I doing wrong ? I’m following the tutorial I found here : Building a To-Do List React App with Dgraph - Dgraph Blog
And both in the page and the github the author is using deleteJson
, I know I’m using vue instead of react but this not supposed to change anything in dgraph transactions