You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus-docs/docs/dql/dql-mutation.md
+28-17Lines changed: 28 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,8 @@ In DQL, you add data using a set mutation, identified by the `set` keyword.
50
50
```
51
51
</TabItem>
52
52
<TabItemvalue="rdf"label="RDF">
53
-
```
53
+
triples are in [RDF](dql-rdf) format.
54
+
```sh
54
55
{
55
56
set {
56
57
# triples in here
@@ -62,8 +63,8 @@ In DQL, you add data using a set mutation, identified by the `set` keyword.
62
63
}
63
64
}
64
65
```
65
-
66
-
triples are in [RDF](dql-rdf) format.
66
+
</TabItem>
67
+
</Tabs>
67
68
68
69
### Node reference
69
70
A mutation can include a blank nodes as an identifier for the subject or object, or a known UID.
@@ -87,8 +88,7 @@ will add the `release_date` information to the node identified by UID `0x632ea2`
87
88
}
88
89
```
89
90
90
-
</TabItem>
91
-
</Tabs>
91
+
92
92
93
93
94
94
## delete block
@@ -127,14 +127,9 @@ indexing) is removed with the pattern `S P *`.
127
127
}
128
128
```
129
129
130
-
The pattern `S * *` deletes all the known edges out of a node, any reverse edges
130
+
The pattern `S * *` deletes all predicates from a node`S`, along with any reverse edges
131
131
corresponding to the removed edges, and any indexing for the removed data.
132
132
133
-
:::note For mutations that fit the `S * *` pattern, only
134
-
predicates that are among the types associated with a given node (using
135
-
`dgraph.type`) are deleted. Any predicates that don't match one of the
136
-
node's types will remain after an `S * *` delete mutation.:::
137
-
138
133
```sh
139
134
{
140
135
delete {
@@ -143,13 +138,29 @@ node's types will remain after an `S * *` delete mutation.:::
143
138
}
144
139
```
145
140
146
-
If the node `S` in the delete pattern `S * *` has only a few predicates with a
147
-
type defined by `dgraph.type`, then only those triples with typed predicates are
148
-
deleted. A node that contains untyped predicates will still exist after a
149
-
`S * *` delete mutation.
141
+
:::note
142
+
When using the `S * *` pattern, Dgraph only deletes predicates that are defined in the types associated with the node via `dgraph.type`.
143
+
144
+
For example, if a node has `dgraph.type: ["Person", "Author"]`, and the `Person` type defines predicates `name`, `age`, and `email`, while the `Author` type defines predicates `name` and `author.of`, then `S * *` will only delete triples for predicates that appear in at least one of these types (`name`, `age`, `email`, `author.of`).
145
+
146
+
Any predicates on the node that are not defined in any of the node's types will remain after the `S * *` delete mutation. This means:
147
+
- If a node has untyped predicates (predicates not in any `dgraph.type`), those predicates will not be deleted.
148
+
- If a node has no `dgraph.type` assigned, `S * *` will have no effect.
149
+
:::
150
+
151
+
**Example:**
152
+
153
+
Consider a node with UID `0x123` that has:
154
+
-`dgraph.type: "Person"` (where `Person` type defines `name`, `age`, `email`)
155
+
- Predicate `name: "Alice"` (typed - will be deleted)
156
+
- Predicate `age: "30"` (typed - will be deleted)
157
+
- Predicate `custom_field: "value"` (untyped - will NOT be deleted)
158
+
159
+
After executing `delete { <0x123> * * . }`, the node will still exist with only `custom_field: "value"` remaining.
150
160
151
-
:::note The patterns `* P O` and `* * O` are not supported because
152
-
it's inefficient to store and find all the incoming edges. :::
161
+
:::note
162
+
The patterns `* P O` and `* * O` are not supported.
Copy file name to clipboardExpand all lines: docusaurus-docs/docs/dql/index.md
+29-1Lines changed: 29 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,35 @@ Dgraph stores data as facts using predicates. Each fact follows the pattern: `<n
21
21
22
22
For detailed definitions, see the [Dgraph Glossary](/dgraph-glossary) and [design concepts](/design-concepts/relationships-concept).
23
23
24
-
---
24
+
## Transactions
25
+
26
+
Dgraph supports transactions to ensure data consistency and atomicity. A transaction groups multiple operations (queries and mutations) into a single atomic unit.
27
+
28
+
### Transaction Lifecycle
29
+
30
+
1.**Start a transaction**: When you execute a query or mutation, Dgraph automatically starts a new transaction and assigns it a unique transaction ID (also called `start_ts` or start timestamp).
31
+
32
+
2.**Execute operations**: Within a transaction, you can perform multiple queries and mutations. All operations in the same transaction use the same transaction ID to ensure they see a consistent view of the data.
33
+
34
+
3.**Commit or rollback**:
35
+
-**Commit**: Makes all changes in the transaction permanent. After committing, the changes are visible to other transactions.
36
+
-**Rollback (abort)**: Discards all changes in the transaction. The database returns to its state before the transaction started.
37
+
38
+
### Transaction Contents
39
+
40
+
A transaction can contain:
41
+
-**Queries**: Read data from the database
42
+
-**Mutations**: Add, modify, or delete data
43
+
44
+
You can perform multiple queries and mutations within a single transaction before committing. This allows you to read data, make decisions based on that data, and then apply mutations—all while maintaining consistency.
45
+
46
+
### Read-Only Transactions
47
+
48
+
Read-only transactions are optimized for read operations and cannot contain mutations. They are useful to increase read speed because they can circumvent the usual consensus protocol. Attempting to perform a mutation in a read-only transaction will result in an error.
49
+
50
+
Read-only queries can optionally be set as **best-effort**. Using this flag asks the Dgraph Alpha to try to get timestamps from memory on a best-effort basis to reduce the number of outbound requests to Zero. This may yield improved latencies in read-bound workloads where linearizable reads are not strictly needed.
51
+
52
+
For more details, see [Transactions](../design-concepts/transactions-concept) and [DQL Query](query/dql-query).
0 commit comments