arangojs
Version:
The official ArangoDB JavaScript driver.
40 lines • 1.09 kB
JavaScript
/**
* ```ts
* import type {
* FulltextIndex,
* GeoIndex,
* MdiIndex,
* PersistentIndex,
* PrimaryIndex,
* TtlIndex,
* } from "arangojs/indexes.js";
* ```
*
* The "indexes" module provides index-related types for TypeScript.
*
* @packageDocumentation
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports._indexHandle = void 0;
/**
* @internal
*/
function _indexHandle(selector, collectionName) {
if (typeof selector !== "string") {
if (selector.id) {
return _indexHandle(selector.id, collectionName);
}
throw new Error("Index handle must be a string or an object with an id attribute");
}
if (selector.includes("/")) {
const [head] = selector.split("/");
if (head !== collectionName) {
throw new Error(`Index ID "${selector}" does not match collection name "${collectionName}"`);
}
return selector;
}
return `${collectionName}/${String(selector)}`;
}
exports._indexHandle = _indexHandle;
//# sourceMappingURL=indexes.js.map
;