Update an Item attribute

Is there an update item option with the dgraph-js. I do not see it in the documentation

Is the only way to delete the item then create a new item with the new data.

I am using DQL by the way and an example of the type I am using is

type Comment {
	Comment.commentId
	Comment.username
	Comment.likes
	Comment.comment
  Comment.likesCount
}

I would like to increment / decrement Comment.likesCount because I need to orderdesc

The answer is this

async function IncrementOrDecrementHashtagPins(
    hashtag: string,
    increment: boolean
): Promise<boolean> {
    // Hashtag.pinnedByCount: int .
    const txn = dgraphClient.newTxn({});
    try {
        const uid = await GetHashtagUid(hashtag);
        if (!uid) return false;
        const mutation = new dgraph.Mutation();
        if (increment) {
            mutation.setSetNquads(
                `<${uid}> <Hashtag.pinnedByCount> "1"^^<xs:int> .`
            );
        } else {
            mutation.setSetNquads(
                `<${uid}> <Hashtag.pinnedByCount> "-1"^^<xs:int> .`
            );
        }
        await txn.mutate(mutation);
        await txn.commit();
        return true;
    } catch (err) {
        return false;
    } finally {
        await txn.discard();
    }
}

Try to use Upsert Block. You can use math to do sum or subtraction. In one Upsert you can do math(Var1+1) and in the other you can do something like “math(var1-1)”.

is one better than the other in terms of speed or error handling?

There’s no error handling in DQL.
Upserts are better cuz it checks for the value on the fly and does the upsert. It guarantees unicity.