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: docs/content/interacting/relationship-queries.mdx
+75-9Lines changed: 75 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,13 +198,34 @@ The [Read API](/api/service#Relationship%20Tuples/Read) is an API endpoint that
198
198
199
199
Read can be called if you need to get all the stored relationship tuples that relate:
200
200
201
-
1.[a particular user to any objects of a specific type with a particular relation](#1-a-particular-user-to-any-objects-of-a-specific-type-with-a-particular-relation)
202
-
2.[a particular user to any objects of a specific type with any relation](#2-a-particular-user-to-any-objects-of-a-specific-type-with-any-relation)
203
-
3.[a particular object to any user with a particular relation](#3-a-particular-object-to-any-user-with-a-particular-relation)
3.[**user + object** with any relation](#3-read-all-tuples-related-to-a-particular-user-and-object-with-any-relation)
204
+
4.[**user + object type** with any relation](#4-read-all-tuples-related-to-a-particular-user-and-object-type-with-any-relation)
205
+
5.[**relation + object** for any user](#5-read-all-tuples-related-to-a-particular-relation-and-object-for-any-user)
206
+
6.[**object** with any user and relation](#6-read-all-tuples-related-to-a-particular-object-with-any-user-or-relation)
207
+
7.[**all** with any user, relation, or object](#7-read-all-tuples-for-any-user-relation-or-object)
204
208
205
-
#### 1. A particular user to any objects of a specific type with a particular relation
209
+
#### 1. Read a tuple related to a particular user, relation, and object
206
210
207
-
For example, to query all the stored relationship tuples `bob` has a `writer` relationship with, one can ask
211
+
For example, to query if `bob` has a `writer` relationship on `document:planning` (essentially finding out if a tuple exists), one can ask
212
+
213
+
<ReadRequestViewer
214
+
user={'user:bob'}
215
+
relation={'writer'}
216
+
object={'document:planning'}
217
+
tuples={[
218
+
{
219
+
user: 'user:bob',
220
+
relation: 'writer',
221
+
object: 'document:planning',
222
+
},
223
+
]}
224
+
/>
225
+
226
+
#### 2. Read all tuples related to a particular user, relation, and object type
227
+
228
+
For example, to query all the stored relationship tuples `bob` has a `writer` relationship with on type `document:`, one can ask
208
229
209
230
<ReadRequestViewer
210
231
user={'user:bob'}
@@ -219,9 +240,25 @@ For example, to query all the stored relationship tuples `bob` has a `writer` re
219
240
]}
220
241
/>
221
242
222
-
#### 2. A particular user to any objects of a specific type with any relation
243
+
#### 3. Read all tuples related to a particular user and object with any relation
244
+
245
+
For example, to query all the stored relationship tuples `bob` has on type `document:planning`, one can ask
246
+
247
+
<ReadRequestViewer
248
+
user={'user:bob'}
249
+
object={'document:planning'}
250
+
tuples={[
251
+
{
252
+
user: 'user:bob',
253
+
relation: 'writer',
254
+
object: 'document:planning',
255
+
},
256
+
]}
257
+
/>
258
+
259
+
#### 4. Read all tuples related to a particular user and object type with any relation
223
260
224
-
For example, to query all the stored relationship tuples in which `bob`is related to objects of type `document` as any relation, one can issue the following call:
261
+
For example, to query all the stored relationship tuples `bob`has on object type `document:`, one can ask
225
262
226
263
<ReadRequestViewer
227
264
user={'user:bob'}
@@ -235,9 +272,9 @@ For example, to query all the stored relationship tuples in which `bob` is relat
235
272
]}
236
273
/>
237
274
238
-
#### 3. A particular object to any user with a particular relation
275
+
#### 5. Read all tuples related to a particular relation and object for any user
239
276
240
-
For example, to query all the stored relationship tuples in which any user is related to `document:planning` as a `writer`, one can issue the following call:
277
+
For example, to query all the stored relationship tuples which have the `writer` relation on object `document:planning`, one can ask
241
278
242
279
<ReadRequestViewer
243
280
relation={'writer'}
@@ -251,6 +288,35 @@ For example, to query all the stored relationship tuples in which any user is re
251
288
]}
252
289
/>
253
290
291
+
#### 6. Read all tuples related to a particular object with any user or relation
292
+
293
+
For example, to query all the stored relationship tuples for object `document:planning`, one can ask
294
+
295
+
<ReadRequestViewer
296
+
object={'document:planning'}
297
+
tuples={[
298
+
{
299
+
user: 'user:bob',
300
+
relation: 'writer',
301
+
object: 'document:planning',
302
+
},
303
+
]}
304
+
/>
305
+
306
+
#### 7. Read all tuples for any user, relation, or object
307
+
308
+
For example, to query all stored relationship tuples, one can ask
309
+
310
+
<ReadRequestViewer
311
+
tuples={[
312
+
{
313
+
user: 'user:bob',
314
+
relation: 'writer',
315
+
object: 'document:planning',
316
+
},
317
+
]}
318
+
/>
319
+
254
320
### Caveats and when not to use it
255
321
256
322
The Read API will only return all the stored relationships that match the query specification.
0 commit comments