forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocuments.js
More file actions
36 lines (36 loc) · 1.12 KB
/
Copy pathdocuments.js
File metadata and controls
36 lines (36 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
/**
* ```ts
* import type { Document, Edge } from "arangojs/documents";
* ```
*
* The "documents" module provides document/edge related types for TypeScript.
*
* @packageDocumentation
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports._documentHandle = void 0;
/**
* @internal
* @hidden
*/
function _documentHandle(selector, collectionName, strict = true) {
if (typeof selector !== "string") {
if (selector._id) {
return _documentHandle(selector._id, collectionName);
}
if (selector._key) {
return _documentHandle(selector._key, collectionName);
}
throw new Error("Document handle must be a string or an object with a _key or _id attribute");
}
if (selector.includes("/")) {
if (strict && !selector.startsWith(`${collectionName}/`)) {
throw new Error(`Document ID "${selector}" does not match collection name "${collectionName}"`);
}
return selector;
}
return `${collectionName}/${selector}`;
}
exports._documentHandle = _documentHandle;
//# sourceMappingURL=documents.js.map