-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Description
When doing an upsert, it is not clear how to get the result of the upsert.
E.g:
def upsert(client, name, state):
q = """query q($name: string)
{
NODE as q(func: eq(name, $name)) {
expand(_all_)
}
}"""
txn = client.txn()
state['uid'] = 'uid(NODE)'
m = txn.create_mutation(set_obj=state, cond='@if(eq(len(NODE), 1))')
request = txn.create_request(query=q,
mutations=(m,),
variables={'$name': name},
commit_now=True)
try:
result = txn.do_request(request)
finally:
txn.discard()It would seem intuitive to have the newly changed state accessible in result.json, but reading this attribute returns b''.
What's the intended way of getting the newly updated state? Make a new query? That would seem redundant to me, but perhaps there are good reasons to have the user explicitly make a new query.
Upon further contemplation, you could simply return state as that should be your updated data, but then it is unclear how to idiomatically check if the request caused a write to the db.
EDIT: Updated example with setting uid, but the issue still persists.
Metadata
Metadata
Assignees
Labels
No labels