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: spec/14-extensions.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,3 +198,72 @@ geo_distance_validate(args):
198
198
199
199
- If the length of {args} is not 2:
200
200
- Report an error.
201
+
202
+
## Documents Extension
203
+
204
+
Functions available in Documents extension are grouped under the `documents` namespace.
205
+
206
+
### Global Document Reference type
207
+
208
+
A Global Document Reference (GDR) type represents a reference to a document. The referenced document can be in a dataset separate from the dataset of the query context in the current scope.
209
+
210
+
A GDR consists of a string formatted to uniquely identify a dataset and a document within that dataset.
211
+
212
+
MatchesGDR({gdr}, {datasetID}, {documentID}):
213
+
214
+
- If {gdr} is not a string:
215
+
- Return {false}.
216
+
- If {gdr} is not in a valid Global Document Reference format:
217
+
- Return {false}.
218
+
- Let {gdrDatasetID} be the unique identifier for the dataset identified by {gdr}.
219
+
- Let {gdrDocumentID} be the unique identifier for the document identified by {gdr}.
220
+
- If {Equal(gdrDatasetID, datasetID)} is {true} and {Equal(gdrDatasetID, datasetID)} is {true}:
221
+
- Return {true}.
222
+
- Otherwise:
223
+
- Return {false}.
224
+
225
+
### documents::get()
226
+
227
+
This function takes a Global Document Reference referencing a document and returns the document.
228
+
229
+
documents_get(args, scope):
230
+
231
+
- Let {gdrNode} be the first element of {args}.
232
+
- Let {gdr} be the result of {Evaluate(gdrNode, scope)}.
233
+
- If {gdr} is not a string:
234
+
- Return {null}.
235
+
- If {gdr} is not in a valid Global Document Reference format:
236
+
- Return {null}.
237
+
- Let {sources} be a list of other data sources in the query context of {scope}.
238
+
- For each {source} in {sources}:
239
+
- If {source} is a dataset:
240
+
- Let {datasetID} be a unique identifier for the {source} dataset.
241
+
- For each {document} in the {source} dataset:
242
+
- If {document} is an object and has an attribute `_id`:
243
+
- Let {documentID} be the value of the attribute `_id` in {document}.
244
+
- If {MatchesGDR(gdr, datasetID, documentID)} is {true}:
- Let {\_incomingGDRCount} be a property of {document} which represents the number of Global Document References referencing {document}. This property is updated whenever a Global Document Reference to {document} is created or deleted.
0 commit comments