Skip to content

Add Running an Upsert #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,29 @@ Number of people named "Alice": 1
Alice
```

### Running an Upsert

Txn#mutate(Mutation) runs mutations and upsert transactions. It takes in a Mutation object, which provides two data formats: JSON and RDF N-Quad. You can choose whichever way is convenient.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right. @prashant-shahi please have a discussion about this with me. Something seems off.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please DO NOT MERGE.


To know more about upsert, we highly recommend going through the docs at https://docs.dgraph.io/mutations/#upsert-block.

```js
// Create data.
const p = {
query:"{v as var(func: eq(email, \"user@company1.io\"))}",
set:[
{
"uid":"uid(v)",
"name":"first last",
"email":"user@company1.io"
}
]
};

// Run mutation.
await txn.mutate({ mutation: JSON.stringify(p), commitNow: true });
```

### Commit a transaction

A transaction can be committed using the `Txn#commit()` method. If your transaction
Expand Down