@@ -28,20 +28,22 @@ import {
2828import { HttpError , isArangoError } from "./error.js" ;
2929import {
3030 EnsureGeoIndexOptions ,
31+ EnsureIndexOptions ,
3132 EnsureInvertedIndexOptions ,
33+ EnsureMdiIndexOptions ,
34+ EnsureMdiPrefixedIndexOptions ,
3235 EnsurePersistentIndexOptions ,
3336 EnsureTtlIndexOptions ,
34- EnsureMdiIndexOptions ,
3537 GeoIndex ,
38+ HiddenIndex ,
3639 Index ,
3740 IndexSelector ,
3841 InvertedIndex ,
42+ MdiIndex ,
43+ MdiPrefixedIndex ,
3944 PersistentIndex ,
4045 TtlIndex ,
41- MdiIndex ,
4246 _indexHandle ,
43- EnsureIndexOptions ,
44- HiddenIndex ,
4547} from "./indexes.js" ;
4648import { COLLECTION_NOT_FOUND , DOCUMENT_NOT_FOUND } from "./lib/codes.js" ;
4749
@@ -1254,7 +1256,7 @@ export interface DocumentCollection<
12541256 ) : Promise <
12551257 ArangoApiResponse <
12561258 CollectionMetadata &
1257- CollectionProperties & { count : number ; figures : Record < string , any > }
1259+ CollectionProperties & { count : number ; figures : Record < string , any > }
12581260 >
12591261 > ;
12601262 /**
@@ -1341,7 +1343,9 @@ export interface DocumentCollection<
13411343 * // the collection "some-collection" is now empty
13421344 * ```
13431345 */
1344- truncate ( options ?: CollectionTruncateOptions ) : Promise < ArangoApiResponse < CollectionMetadata > > ;
1346+ truncate (
1347+ options ?: CollectionTruncateOptions
1348+ ) : Promise < ArangoApiResponse < CollectionMetadata > > ;
13451349 /**
13461350 * Deletes the collection from the database.
13471351 *
@@ -1589,9 +1593,9 @@ export interface DocumentCollection<
15891593 ) : Promise <
15901594 Array <
15911595 | ( DocumentOperationMetadata & {
1592- new ?: Document < EntryResultType > ;
1593- old ?: Document < EntryResultType > ;
1594- } )
1596+ new ?: Document < EntryResultType > ;
1597+ old ?: Document < EntryResultType > ;
1598+ } )
15951599 | DocumentOperationFailure
15961600 >
15971601 > ;
@@ -1661,9 +1665,9 @@ export interface DocumentCollection<
16611665 ) : Promise <
16621666 Array <
16631667 | ( DocumentOperationMetadata & {
1664- new ?: Document < EntryResultType > ;
1665- old ?: Document < EntryResultType > ;
1666- } )
1668+ new ?: Document < EntryResultType > ;
1669+ old ?: Document < EntryResultType > ;
1670+ } )
16671671 | DocumentOperationFailure
16681672 >
16691673 > ;
@@ -1733,9 +1737,9 @@ export interface DocumentCollection<
17331737 ) : Promise <
17341738 Array <
17351739 | ( DocumentOperationMetadata & {
1736- new ?: Document < EntryResultType > ;
1737- old ?: Document < EntryResultType > ;
1738- } )
1740+ new ?: Document < EntryResultType > ;
1741+ old ?: Document < EntryResultType > ;
1742+ } )
17391743 | DocumentOperationFailure
17401744 >
17411745 > ;
@@ -2022,6 +2026,28 @@ export interface DocumentCollection<
20222026 ensureIndex (
20232027 details : EnsureMdiIndexOptions
20242028 ) : Promise < ArangoApiResponse < MdiIndex & { isNewlyCreated : boolean } > > ;
2029+ /**
2030+ * Creates a prefixed multi-dimensional index on the collection if it does not already exist.
2031+ *
2032+ * @param details - Options for creating the prefixed multi-dimensional index.
2033+ *
2034+ * @example
2035+ * ```js
2036+ * const db = new Database();
2037+ * const collection = db.collection("some-points");
2038+ * // Create a multi-dimensional index for the attributes x, y and z
2039+ * await collection.ensureIndex({
2040+ * type: "mdi-prefixed",
2041+ * fields: ["x", "y", "z"],
2042+ * prefixFields: ["x"],
2043+ * fieldValueTypes: "double"
2044+ * });
2045+ * ```
2046+ * ```
2047+ */
2048+ ensureIndex (
2049+ details : EnsureMdiPrefixedIndexOptions
2050+ ) : Promise < ArangoApiResponse < MdiPrefixedIndex & { isNewlyCreated : boolean } > > ;
20252051 /**
20262052 * Creates a geo index on the collection if it does not already exist.
20272053 *
@@ -2294,9 +2320,9 @@ export interface EdgeCollection<
22942320 ) : Promise <
22952321 Array <
22962322 | ( DocumentOperationMetadata & {
2297- new ?: Edge < EntryResultType > ;
2298- old ?: Edge < EntryResultType > ;
2299- } )
2323+ new ?: Edge < EntryResultType > ;
2324+ old ?: Edge < EntryResultType > ;
2325+ } )
23002326 | DocumentOperationFailure
23012327 >
23022328 > ;
@@ -2390,9 +2416,9 @@ export interface EdgeCollection<
23902416 ) : Promise <
23912417 Array <
23922418 | ( DocumentOperationMetadata & {
2393- new ?: Edge < EntryResultType > ;
2394- old ?: Edge < EntryResultType > ;
2395- } )
2419+ new ?: Edge < EntryResultType > ;
2420+ old ?: Edge < EntryResultType > ;
2421+ } )
23962422 | DocumentOperationFailure
23972423 >
23982424 > ;
@@ -2484,9 +2510,9 @@ export interface EdgeCollection<
24842510 ) : Promise <
24852511 Array <
24862512 | ( DocumentOperationMetadata & {
2487- new ?: Edge < EntryResultType > ;
2488- old ?: Edge < EntryResultType > ;
2489- } )
2513+ new ?: Edge < EntryResultType > ;
2514+ old ?: Edge < EntryResultType > ;
2515+ } )
24902516 | DocumentOperationFailure
24912517 >
24922518 > ;
@@ -2744,12 +2770,13 @@ export interface EdgeCollection<
27442770 * @internal
27452771 */
27462772export class Collection <
2747- EntryResultType extends Record < string , any > = any ,
2748- EntryInputType extends Record < string , any > = EntryResultType ,
2749- >
2773+ EntryResultType extends Record < string , any > = any ,
2774+ EntryInputType extends Record < string , any > = EntryResultType ,
2775+ >
27502776 implements
2751- EdgeCollection < EntryResultType , EntryInputType > ,
2752- DocumentCollection < EntryResultType , EntryInputType > {
2777+ EdgeCollection < EntryResultType , EntryInputType > ,
2778+ DocumentCollection < EntryResultType , EntryInputType >
2779+ {
27532780 //#region attributes
27542781 protected _name : string ;
27552782 protected _db : Database ;
@@ -2880,9 +2907,9 @@ export class Collection<
28802907 details = false
28812908 ) : Promise <
28822909 CollectionMetadata &
2883- ArangoApiResponse <
2884- CollectionProperties & { count : number ; figures : Record < string , any > }
2885- >
2910+ ArangoApiResponse <
2911+ CollectionProperties & { count : number ; figures : Record < string , any > }
2912+ >
28862913 > {
28872914 return this . _db . request ( {
28882915 path : `/_api/collection/${ encodeURIComponent ( this . _name ) } /figures` ,
@@ -2931,7 +2958,9 @@ export class Collection<
29312958 return result ;
29322959 }
29332960
2934- truncate ( options ?: CollectionTruncateOptions ) : Promise < ArangoApiResponse < CollectionMetadata > > {
2961+ truncate (
2962+ options ?: CollectionTruncateOptions
2963+ ) : Promise < ArangoApiResponse < CollectionMetadata > > {
29352964 return this . _db . request ( {
29362965 method : "PUT" ,
29372966 path : `/_api/collection/${ this . _name } /truncate` ,
@@ -3268,6 +3297,7 @@ export class Collection<
32683297 | EnsureGeoIndexOptions
32693298 | EnsureTtlIndexOptions
32703299 | EnsureMdiIndexOptions
3300+ | EnsureMdiPrefixedIndexOptions
32713301 | EnsureInvertedIndexOptions
32723302 ) {
32733303 return this . _db . request ( {
0 commit comments