UNPKG

35.9 kBTypeScriptView Raw
1/**
2 * ```ts
3 * import type {
4 * Graph,
5 * GraphVertexCollection,
6 * GraphEdgeCollection,
7 * } from "arangojs/graph.js";
8 * ```
9 *
10 * The "graph" module provides graph related types and interfaces
11 * for TypeScript.
12 *
13 * @packageDocumentation
14 */
15import { ArangoCollection, DocumentCollection, EdgeCollection } from "./collection.js";
16import { Database } from "./database.js";
17import { Document, DocumentData, DocumentMetadata, DocumentSelector, Edge, EdgeData, Patch } from "./documents.js";
18/**
19 * Indicates whether the given value represents a {@link graph.Graph}.
20 *
21 * @param graph - A value that might be a Graph.
22 */
23export declare function isArangoGraph(graph: any): graph is Graph;
24/**
25 * Options for retrieving a document from a graph collection.
26 */
27export type GraphCollectionReadOptions = {
28 /**
29 * If set to a document revision, the document will only be returned if its
30 * `_rev` property matches this value.
31 *
32 * See also {@link documents.DocumentMetadata}.
33 */
34 rev?: string;
35 /**
36 * If set to `true`, `null` is returned instead of an exception being thrown
37 * if the document does not exist.
38 *
39 * Default: `false`
40 */
41 graceful?: boolean;
42 /**
43 * If set to `true`, the request will explicitly permit ArangoDB to return a
44 * potentially dirty or stale result and arangojs will load balance the
45 * request without distinguishing between leaders and followers.
46 *
47 * Default: `false`
48 */
49 allowDirtyRead?: boolean;
50};
51/**
52 * Options for inserting a document into a graph collection.
53 */
54export type GraphCollectionInsertOptions = {
55 /**
56 * If set to `true`, data will be synchronized to disk before returning.
57 *
58 * Default: `false`
59 */
60 waitForSync?: boolean;
61 /**
62 * If set to `true`, the complete new document will be returned as the `new`
63 * property on the result object.
64 *
65 * Default: `false`
66 */
67 returnNew?: boolean;
68};
69/**
70 * Options for replacing a document in a graph collection.
71 */
72export type GraphCollectionReplaceOptions = {
73 /**
74 * If set to a document revision, the document will only be modified if its
75 * `_rev` property matches this value.
76 *
77 * See also {@link documents.DocumentMetadata}.
78 */
79 rev?: string;
80 /**
81 * If set to `true`, data will be synchronized to disk before returning.
82 *
83 * Default: `false`
84 */
85 waitForSync?: boolean;
86 /**
87 * If set to `false`, properties with a value of `null` will be removed from
88 * the new document.
89 *
90 * Default: `true`
91 */
92 keepNull?: boolean;
93 /**
94 * If set to `true`, the complete old document will be returned as the `old`
95 * property on the result object.
96 *
97 * Default: `false`
98 */
99 returnOld?: boolean;
100 /**
101 * If set to `true`, the complete new document will be returned as the `new`
102 * property on the result object.
103 *
104 * Default: `false`
105 */
106 returnNew?: boolean;
107};
108/**
109 * Options for removing a document from a graph collection.
110 */
111export type GraphCollectionRemoveOptions = {
112 /**
113 * If set to a document revision, the document will only be removed if its
114 * `_rev` property matches this value.
115 *
116 * See also {@link documents.DocumentMetadata}.
117 */
118 rev?: string;
119 /**
120 * If set to `true`, data will be synchronized to disk before returning.
121 *
122 * Default: `false`
123 */
124 waitForSync?: boolean;
125 /**
126 * If set to `true`, the complete old document will be returned as the `old`
127 * property on the result object.
128 *
129 * Default: `false`
130 */
131 returnOld?: boolean;
132};
133/**
134 * Definition of a relation in a {@link graph.Graph}.
135 */
136export type EdgeDefinition = {
137 /**
138 * Name of the collection containing the edges.
139 */
140 collection: string;
141 /**
142 * Array of names of collections containing the start vertices.
143 */
144 from: string[];
145 /**
146 * Array of names of collections containing the end vertices.
147 */
148 to: string[];
149};
150/**
151 * An edge definition used to define a collection of edges in a {@link graph.Graph}.
152 */
153export type EdgeDefinitionOptions = {
154 /**
155 * Collection containing the edges.
156 */
157 collection: string | ArangoCollection;
158 /**
159 * Collection or collections containing the start vertices.
160 */
161 from: (string | ArangoCollection)[] | string | ArangoCollection;
162 /**
163 * Collection or collections containing the end vertices.
164 */
165 to: (string | ArangoCollection)[] | string | ArangoCollection;
166};
167/**
168 * General information about a graph.
169 */
170export type GraphInfo = {
171 /**
172 * Key of the document internally representing this graph.
173 *
174 * See {@link documents.DocumentMetadata}.
175 *
176 * @internal
177 */
178 _key: string;
179 /**
180 * Unique identifier of the document internally representing this graph.
181 *
182 * See {@link documents.DocumentMetadata}.
183 *
184 * @internal
185 */
186 _id: string;
187 /**
188 * Revision of the document internally representing this graph.
189 *
190 * See {@link documents.DocumentMetadata}.
191 *
192 * @internal
193 */
194 _rev: string;
195 /**
196 * Name of the graph.
197 */
198 name: string;
199 /**
200 * Definitions for the relations of the graph.
201 */
202 edgeDefinitions: EdgeDefinition[];
203 /**
204 * Additional vertex collections. Documents within these collections do not
205 * have edges within this graph.
206 */
207 orphanCollections: string[];
208 /**
209 * (Cluster only.) Number of shards that is used for every collection
210 * within this graph.
211 */
212 numberOfShards?: number;
213 /**
214 * (Cluster only.) Replication factor used when initially creating
215 * collections for this graph.
216 */
217 replicationFactor?: number;
218 /**
219 * (Cluster only.) Write concern for new collections in the graph.
220 */
221 writeConcern?: number;
222 /**
223 * (Enterprise Edition cluster only.) If set to `true`, the graph is a
224 * SatelliteGraph.
225 */
226 isSatellite?: boolean;
227 /**
228 * (Enterprise Edition cluster only.) If set to `true`, the graph has been
229 * created as a SmartGraph.
230 */
231 isSmart?: boolean;
232 /**
233 * (Enterprise Edition cluster only.) Attribute containing the shard key
234 * value to use for smart sharding.
235 */
236 smartGraphAttribute?: string;
237 /**
238 * (Enterprise Edition cluster only.) If set to `true`, the graph has been
239 * created as a Disjoint SmartGraph.
240 */
241 isDisjoint?: boolean;
242};
243/**
244 * Option for creating a graph.
245 */
246export type CreateGraphOptions = {
247 /**
248 * If set to `true`, the request will wait until all modifications have been
249 * synchronized to disk before returning successfully.
250 *
251 * Default: `false`
252 */
253 waitForSync?: boolean;
254 /**
255 * Additional vertex collections. Documents within these collections do not
256 * have edges within this graph.
257 */
258 orphanCollections?: (string | ArangoCollection)[] | string | ArangoCollection;
259 /**
260 * (Cluster only.) Number of shards that is used for every collection
261 * within this graph.
262 *
263 * Has no effect when `replicationFactor` is set to `"satellite"`.
264 */
265 numberOfShards?: number;
266 /**
267 * (Cluster only.) Replication factor used when initially creating
268 * collections for this graph.
269 *
270 * Default: `1`
271 */
272 replicationFactor?: number | "satellite";
273 /**
274 * (Cluster only.) Write concern for new collections in the graph.
275 *
276 * Has no effect when `replicationFactor` is set to `"satellite"`.
277 */
278 writeConcern?: number;
279 /**
280 * (Enterprise Edition cluster only.) If set to `true`, the graph will be
281 * created as a SmartGraph.
282 *
283 * Default: `false`
284 */
285 isSmart?: boolean;
286 /**
287 * (Enterprise Edition cluster only.) Attribute containing the shard key
288 * value to use for smart sharding.
289 */
290 smartGraphAttribute?: string;
291 /**
292 * (Enterprise Edition cluster only.) If set to `true`, the graph will be
293 * created as a Disjoint SmartGraph.
294 *
295 * Default: `false`
296 */
297 isDisjoint?: boolean;
298 /**
299 * (Enterprise Edition cluster only.) Collections to be included in a Hybrid
300 * SmartGraph.
301 */
302 satellites?: (string | ArangoCollection)[];
303};
304export type AddVertexCollectionOptions = {
305 /**
306 * (Enterprise Edition cluster only.) Collections to be included in a Hybrid
307 * SmartGraph.
308 */
309 satellites?: (string | ArangoCollection)[];
310};
311export type AddEdgeDefinitionOptions = {
312 /**
313 * (Enterprise Edition cluster only.) Collections to be included in a Hybrid
314 * SmartGraph.
315 */
316 satellites?: (string | ArangoCollection)[];
317};
318export type ReplaceEdgeDefinitionOptions = {
319 /**
320 * (Enterprise Edition cluster only.) Collections to be included in a Hybrid
321 * SmartGraph.
322 */
323 satellites?: string[];
324};
325/**
326 * Represents a {@link collection.DocumentCollection} of vertices in a {@link graph.Graph}.
327 *
328 * @param T - Type to use for document data. Defaults to `any`.
329 */
330export declare class GraphVertexCollection<T extends Record<string, any> = any> implements ArangoCollection {
331 protected _db: Database;
332 protected _name: string;
333 protected _graph: Graph;
334 protected _collection: DocumentCollection<T>;
335 /**
336 * @internal
337 */
338 constructor(db: Database, name: string, graph: Graph);
339 /**
340 * @internal
341 *
342 * Indicates that this object represents an ArangoDB collection.
343 */
344 get isArangoCollection(): true;
345 /**
346 * Name of the collection.
347 */
348 get name(): string;
349 /**
350 * A {@link collection.DocumentCollection} instance for this vertex collection.
351 */
352 get collection(): DocumentCollection<T, T>;
353 /**
354 * The {@link graph.Graph} instance this vertex collection is bound to.
355 */
356 get graph(): Graph;
357 /**
358 * Checks whether a vertex matching the given key or id exists in this
359 * collection.
360 *
361 * Throws an exception when passed a vertex or `_id` from a different
362 * collection.
363 *
364 * @param selector - Document `_key`, `_id` or object with either of those
365 * properties (e.g. a vertex from this collection).
366 *
367 * @example
368 * ```js
369 * const graph = db.graph("some-graph");
370 * const collection = graph.vertexCollection("vertices");
371 * const exists = await collection.vertexExists("abc123");
372 * if (!exists) {
373 * console.log("Vertex does not exist");
374 * }
375 * ```
376 */
377 vertexExists(selector: DocumentSelector): Promise<boolean>;
378 /**
379 * Retrieves the vertex matching the given key or id.
380 *
381 * Throws an exception when passed a vertex or `_id` from a different
382 * collection.
383 *
384 * @param selector - Document `_key`, `_id` or object with either of those
385 * properties (e.g. a vertex from this collection).
386 * @param options - Options for retrieving the vertex.
387 *
388 * @example
389 * ```js
390 * const graph = db.graph("some-graph");
391 * const collection = graph.vertexCollection("vertices");
392 * try {
393 * const vertex = await collection.vertex("abc123");
394 * console.log(vertex);
395 * } catch (e: any) {
396 * console.error("Could not find vertex");
397 * }
398 * ```
399 *
400 * @example
401 * ```js
402 * const graph = db.graph("some-graph");
403 * const collection = graph.vertexCollection("vertices");
404 * const vertex = await collection.vertex("abc123", { graceful: true });
405 * if (vertex) {
406 * console.log(vertex);
407 * } else {
408 * console.error("Could not find vertex");
409 * }
410 * ```
411 */
412 vertex(selector: DocumentSelector, options?: GraphCollectionReadOptions): Promise<Document<T>>;
413 /**
414 * Retrieves the vertex matching the given key or id.
415 *
416 * Throws an exception when passed a vertex or `_id` from a different
417 * collection.
418 *
419 * @param selector - Document `_key`, `_id` or object with either of those
420 * properties (e.g. a vertex from this collection).
421 * @param graceful - If set to `true`, `null` is returned instead of an
422 * exception being thrown if the vertex does not exist.
423 *
424 * @example
425 * ```js
426 * const graph = db.graph("some-graph");
427 * const collection = graph.vertexCollection("vertices");
428 * try {
429 * const vertex = await collection.vertex("abc123", false);
430 * console.log(vertex);
431 * } catch (e: any) {
432 * console.error("Could not find vertex");
433 * }
434 * ```
435 *
436 * @example
437 * ```js
438 * const graph = db.graph("some-graph");
439 * const collection = graph.vertexCollection("vertices");
440 * const vertex = await collection.vertex("abc123", true);
441 * if (vertex) {
442 * console.log(vertex);
443 * } else {
444 * console.error("Could not find vertex");
445 * }
446 * ```
447 */
448 vertex(selector: DocumentSelector, graceful: boolean): Promise<Document<T>>;
449 /**
450 * Inserts a new vertex with the given `data` into the collection.
451 *
452 * @param data - The contents of the new vertex.
453 * @param options - Options for inserting the vertex.
454 *
455 * @example
456 * ```js
457 * const graph = db.graph("some-graph");
458 * const collection = graph.vertexCollection("friends");
459 * const result = await collection.save(
460 * { _key: "a", color: "blue", count: 1 },
461 * { returnNew: true }
462 * );
463 * console.log(result.new.color, result.new.count); // "blue" 1
464 * ```
465 */
466 save(data: DocumentData<T>, options?: GraphCollectionInsertOptions): Promise<DocumentMetadata & {
467 new?: Document<T>;
468 }>;
469 /**
470 * Replaces an existing vertex in the collection.
471 *
472 * Throws an exception when passed a vertex or `_id` from a different
473 * collection.
474 *
475 * @param selector - Document `_key`, `_id` or object with either of those
476 * properties (e.g. a vertex from this collection).
477 * @param newData - The contents of the new vertex.
478 * @param options - Options for replacing the vertex.
479 *
480 * @example
481 * ```js
482 * const graph = db.graph("some-graph");
483 * const collection = graph.collection("vertices");
484 * await collection.save({ _key: "a", color: "blue", count: 1 });
485 * const result = await collection.replace(
486 * "a",
487 * { color: "red" },
488 * { returnNew: true }
489 * );
490 * console.log(result.new.color, result.new.count); // "red" undefined
491 * ```
492 */
493 replace(selector: DocumentSelector, newValue: DocumentData<T>, options?: GraphCollectionReplaceOptions): Promise<DocumentMetadata & {
494 new?: Document<T>;
495 old?: Document<T>;
496 }>;
497 /**
498 * Updates an existing vertex in the collection.
499 *
500 * Throws an exception when passed a vertex or `_id` from a different
501 * collection.
502 *
503 * @param selector - Document `_key`, `_id` or object with either of those
504 * properties (e.g. a vertex from this collection).
505 * @param newData - The data for updating the vertex.
506 * @param options - Options for updating the vertex.
507 *
508 * @example
509 * ```js
510 * const graph = db.graph("some-graph");
511 * const collection = graph.collection("vertices");
512 * await collection.save({ _key: "a", color: "blue", count: 1 });
513 * const result = await collection.update(
514 * "a",
515 * { count: 2 },
516 * { returnNew: true }
517 * );
518 * console.log(result.new.color, result.new.count); // "blue" 2
519 * ```
520 */
521 update(selector: DocumentSelector, newValue: Patch<DocumentData<T>>, options?: GraphCollectionReplaceOptions): Promise<DocumentMetadata & {
522 new?: Document<T>;
523 old?: Document<T>;
524 }>;
525 /**
526 * Removes an existing vertex from the collection.
527 *
528 * Throws an exception when passed a vertex or `_id` from a different
529 * collection.
530 *
531 * @param selector - Document `_key`, `_id` or object with either of those
532 * properties (e.g. a vertex from this collection).
533 * @param options - Options for removing the vertex.
534 *
535 * @example
536 * ```js
537 * const graph = db.graph("some-graph");
538 * const collection = graph.vertexCollection("vertices");
539 * await collection.remove("abc123");
540 * // document with key "abc123" deleted
541 * ```
542 *
543 * @example
544 * ```js
545 * const graph = db.graph("some-graph");
546 * const collection = graph.vertexCollection("vertices");
547 * const doc = await collection.vertex("abc123");
548 * await collection.remove(doc);
549 * // document with key "abc123" deleted
550 * ```
551 */
552 remove(selector: DocumentSelector, options?: GraphCollectionRemoveOptions): Promise<DocumentMetadata & {
553 old?: Document<T>;
554 }>;
555}
556/**
557 * Represents a {@link collection.EdgeCollection} of edges in a {@link graph.Graph}.
558 *
559 * @param T - Type to use for document data. Defaults to `any`.
560 */
561export declare class GraphEdgeCollection<T extends Record<string, any> = any> implements ArangoCollection {
562 protected _db: Database;
563 protected _name: string;
564 protected _graph: Graph;
565 protected _collection: EdgeCollection<T>;
566 /**
567 * @internal
568 */
569 constructor(db: Database, name: string, graph: Graph);
570 /**
571 * @internal
572 *
573 * Indicates that this object represents an ArangoDB collection.
574 */
575 get isArangoCollection(): true;
576 /**
577 * Name of the collection.
578 */
579 get name(): string;
580 /**
581 * A {@link collection.EdgeCollection} instance for this edge collection.
582 */
583 get collection(): EdgeCollection<T, T>;
584 /**
585 * The {@link graph.Graph} instance this edge collection is bound to.
586 */
587 get graph(): Graph;
588 /**
589 * Checks whether a edge matching the given key or id exists in this
590 * collection.
591 *
592 * Throws an exception when passed a edge or `_id` from a different
593 * collection.
594 *
595 * @param selector - Document `_key`, `_id` or object with either of those
596 * properties (e.g. a edge from this collection).
597 *
598 * @example
599 * ```js
600 * const graph = db.graph("some-graph");
601 * const collection = graph.edgeCollection("friends")
602 * const exists = await collection.edgeExists("abc123");
603 * if (!exists) {
604 * console.log("Edge does not exist");
605 * }
606 * ```
607 */
608 edgeExists(selector: DocumentSelector): Promise<boolean>;
609 /**
610 * Retrieves the edge matching the given key or id.
611 *
612 * Throws an exception when passed a edge or `_id` from a different
613 * collection, or if the edge does not exist.
614 *
615 * @param selector - Document `_key`, `_id` or object with either of those
616 * properties (e.g. a edge from this collection).
617 * @param options - Options for retrieving the edge.
618 *
619 * @example
620 * ```js
621 * const graph = db.graph("some-graph");
622 * const collection = graph.edgeCollection("friends")
623 * try {
624 * const edge = await collection.edge("abc123");
625 * console.log(edge);
626 * } catch (e: any) {
627 * console.error("Could not find edge");
628 * }
629 * ```
630 *
631 * @example
632 * ```js
633 * const graph = db.graph("some-graph");
634 * const collection = graph.edgeCollection("friends")
635 * const edge = await collection.edge("abc123", { graceful: true });
636 * if (edge) {
637 * console.log(edge);
638 * } else {
639 * console.error("Edge does not exist");
640 * }
641 * ```
642 */
643 edge(selector: DocumentSelector, options?: GraphCollectionReadOptions): Promise<Edge<T>>;
644 /**
645 * Retrieves the edge matching the given key or id.
646 *
647 * Throws an exception when passed a edge or `_id` from a different
648 * collection, or if the edge does not exist.
649 *
650 * @param selector - Document `_key`, `_id` or object with either of those
651 * properties (e.g. a edge from this collection).
652 * @param graceful - If set to `true`, `null` is returned instead of an
653 * exception being thrown if the edge does not exist.
654 *
655 * @example
656 * ```js
657 * const graph = db.graph("some-graph");
658 * const collection = graph.edgeCollection("friends")
659 * try {
660 * const edge = await collection.edge("abc123", false);
661 * console.log(edge);
662 * } catch (e: any) {
663 * console.error("Could not find edge");
664 * }
665 * ```
666 *
667 * @example
668 * ```js
669 * const graph = db.graph("some-graph");
670 * const collection = graph.edgeCollection("friends")
671 * const edge = await collection.edge("abc123", true);
672 * if (edge) {
673 * console.log(edge);
674 * } else {
675 * console.error("Edge does not exist");
676 * }
677 * ```
678 */
679 edge(selector: DocumentSelector, graceful: boolean): Promise<Edge<T>>;
680 /**
681 * Inserts a new edge with the given `data` into the collection.
682 *
683 * @param data - The contents of the new edge.
684 * @param options - Options for inserting the edge.
685 *
686 * @example
687 * ```js
688 * const db = new Database();
689 * const collection = db.collection("friends");
690 * const result = await collection.save(
691 * { _from: "users/rana", _to: "users/mudasir", active: false },
692 * { returnNew: true }
693 * );
694 * ```
695 */
696 save(data: EdgeData<T>, options?: GraphCollectionInsertOptions): Promise<DocumentMetadata & {
697 new?: Edge<T>;
698 }>;
699 /**
700 * Replaces an existing edge in the collection.
701 *
702 * Throws an exception when passed a edge or `_id` from a different
703 * collection.
704 *
705 * @param selector - Document `_key`, `_id` or object with either of those
706 * properties (e.g. a edge from this collection).
707 * @param newData - The contents of the new edge.
708 * @param options - Options for replacing the edge.
709 *
710 * @example
711 * ```js
712 * const db = new Database();
713 * const collection = db.collection("friends");
714 * await collection.save(
715 * {
716 * _key: "musadir",
717 * _from: "users/rana",
718 * _to: "users/mudasir",
719 * active: true,
720 * best: true
721 * }
722 * );
723 * const result = await collection.replace(
724 * "musadir",
725 * { active: false },
726 * { returnNew: true }
727 * );
728 * console.log(result.new.active, result.new.best); // false undefined
729 * ```
730 */
731 replace(selector: DocumentSelector, newValue: EdgeData<T>, options?: GraphCollectionReplaceOptions): Promise<DocumentMetadata & {
732 new?: Edge<T>;
733 old?: Edge<T>;
734 }>;
735 /**
736 * Updates an existing edge in the collection.
737 *
738 * Throws an exception when passed a edge or `_id` from a different
739 * collection.
740 *
741 * @param selector - Document `_key`, `_id` or object with either of those
742 * properties (e.g. a edge from this collection).
743 * @param newData - The data for updating the edge.
744 * @param options - Options for updating the edge.
745 *
746 * @example
747 * ```js
748 * const db = new Database();
749 * const collection = db.collection("friends");
750 * await collection.save(
751 * {
752 * _key: "musadir",
753 * _from: "users/rana",
754 * _to: "users/mudasir",
755 * active: true,
756 * best: true
757 * }
758 * );
759 * const result = await collection.update(
760 * "musadir",
761 * { active: false },
762 * { returnNew: true }
763 * );
764 * console.log(result.new.active, result.new.best); // false true
765 * ```
766 */
767 update(selector: DocumentSelector, newValue: Patch<EdgeData<T>>, options?: GraphCollectionReplaceOptions): Promise<DocumentMetadata & {
768 new?: Edge<T>;
769 old?: Edge<T>;
770 }>;
771 /**
772 * Removes an existing edge from the collection.
773 *
774 * Throws an exception when passed a edge or `_id` from a different
775 * collection.
776 *
777 * @param selector - Document `_key`, `_id` or object with either of those
778 * properties (e.g. a edge from this collection).
779 * @param options - Options for removing the edge.
780 *
781 * @example
782 * ```js
783 * const db = new Database();
784 * const collection = db.collection("friends");
785 * const doc = await collection.edge("musadir");
786 * await collection.remove(doc);
787 * // edge with key "musadir" deleted
788 * ```
789 */
790 remove(selector: DocumentSelector, options?: GraphCollectionRemoveOptions): Promise<DocumentMetadata & {
791 old?: Edge<T>;
792 }>;
793}
794/**
795 * Represents a graph in a {@link database.Database}.
796 */
797export declare class Graph {
798 protected _name: string;
799 protected _db: Database;
800 /**
801 * @internal
802 */
803 constructor(db: Database, name: string);
804 /**
805 * @internal
806 *
807 * Indicates that this object represents an ArangoDB Graph.
808 */
809 get isArangoGraph(): true;
810 /**
811 * Name of the graph.
812 */
813 get name(): string;
814 /**
815 * Checks whether the graph exists.
816 *
817 * @example
818 * ```js
819 * const db = new Database();
820 * const graph = db.graph("some-graph");
821 * const result = await graph.exists();
822 * // result indicates whether the graph exists
823 * ```
824 */
825 exists(): Promise<boolean>;
826 /**
827 * Retrieves general information about the graph.
828 *
829 * @example
830 * ```js
831 * const db = new Database();
832 * const graph = db.graph("some-graph");
833 * const data = await graph.get();
834 * // data contains general information about the graph
835 * ```
836 */
837 get(): Promise<GraphInfo>;
838 /**
839 * Creates a graph with the given `edgeDefinitions` and `options` for this
840 * graph's name.
841 *
842 * @param edgeDefinitions - Definitions for the relations of the graph.
843 * @param options - Options for creating the graph.
844 *
845 * @example
846 * ```js
847 * const db = new Database();
848 * const graph = db.graph("some-graph");
849 * const info = await graph.create([
850 * {
851 * collection: "edges",
852 * from: ["start-vertices"],
853 * to: ["end-vertices"],
854 * },
855 * ]);
856 * // graph now exists
857 * ```
858 */
859 create(edgeDefinitions: EdgeDefinitionOptions[], options?: CreateGraphOptions): Promise<GraphInfo>;
860 /**
861 * Deletes the graph from the database.
862 *
863 * @param dropCollections - If set to `true`, the collections associated with
864 * the graph will also be deleted.
865 *
866 * @example
867 * ```js
868 * const db = new Database();
869 * const graph = db.graph("some-graph");
870 * await graph.drop();
871 * // the graph "some-graph" no longer exists
872 * ```
873 */
874 drop(dropCollections?: boolean): Promise<boolean>;
875 /**
876 * Returns a {@link graph.GraphVertexCollection} instance for the given collection
877 * name representing the collection in this graph.
878 *
879 * @param T - Type to use for document data. Defaults to `any`.
880 * @param collection - Name of the vertex collection.
881 */
882 vertexCollection<T extends Record<string, any> = any>(collection: string | ArangoCollection): GraphVertexCollection<T>;
883 /**
884 * Fetches all vertex collections of this graph from the database and returns
885 * an array of their names.
886 *
887 * See also {@link graph.Graph#vertexCollections}.
888 *
889 * @example
890 * ```js
891 * const db = new Database();
892 * const graph = db.graph("some-graph");
893 * const info = await graph.create([
894 * {
895 * collection: "edges",
896 * from: ["start-vertices"],
897 * to: ["end-vertices"],
898 * },
899 * ]);
900 * const vertexCollectionNames = await graph.listVertexCollections();
901 * // ["start-vertices", "end-vertices"]
902 * ```
903 */
904 listVertexCollections(): Promise<string[]>;
905 /**
906 * Fetches all vertex collections of this graph from the database and returns
907 * an array of {@link graph.GraphVertexCollection} instances.
908 *
909 * See also {@link graph.Graph#listVertexCollections}.
910 *
911 * @example
912 * ```js
913 * const db = new Database();
914 * const graph = db.graph("some-graph");
915 * const info = await graph.create([
916 * {
917 * collection: "edges",
918 * from: ["start-vertices"],
919 * to: ["end-vertices"],
920 * },
921 * ]);
922 * const vertexCollections = await graph.vertexCollections();
923 * for (const vertexCollection of vertexCollections) {
924 * console.log(vertexCollection.name);
925 * // "start-vertices"
926 * // "end-vertices"
927 * }
928 * ```
929 */
930 vertexCollections(): Promise<GraphVertexCollection[]>;
931 /**
932 * Adds the given collection to this graph as a vertex collection.
933 *
934 * @param collection - Collection to add to the graph.
935 *
936 * @example
937 * ```js
938 * const db = new Database();
939 * const graph = db.graph("some-graph");
940 * await graph.addVertexCollection("more-vertices");
941 * // The collection "more-vertices" has been added to the graph
942 * const extra = db.collection("extra-vertices");
943 * await graph.addVertexCollection(extra);
944 * // The collection "extra-vertices" has been added to the graph
945 * ```
946 */
947 addVertexCollection(collection: string | ArangoCollection, options?: AddVertexCollectionOptions): Promise<GraphInfo>;
948 /**
949 * Removes the given collection from this graph as a vertex collection.
950 *
951 * @param collection - Collection to remove from the graph.
952 * @param dropCollection - If set to `true`, the collection will also be
953 * deleted from the database.
954 *
955 * @example
956 * ```js
957 * const db = new Database();
958 * const graph = db.graph("some-graph");
959 * const info = await graph.create([
960 * {
961 * collection: "edges",
962 * from: ["start-vertices"],
963 * to: ["end-vertices"],
964 * },
965 * ]);
966 * await graph.removeVertexCollection("start-vertices");
967 * // The collection "start-vertices" is no longer part of the graph.
968 * ```
969 */
970 removeVertexCollection(collection: string | ArangoCollection, dropCollection?: boolean): Promise<GraphInfo>;
971 /**
972 * Returns a {@link graph.GraphEdgeCollection} instance for the given collection
973 * name representing the collection in this graph.
974 *
975 * @param T - Type to use for document data. Defaults to `any`.
976 * @param collection - Name of the edge collection.
977 *
978 * @example
979 * ```js
980 * const db = new Database();
981 * const graph = db.graph("some-graph");
982 * const info = await graph.create([
983 * {
984 * collection: "edges",
985 * from: ["start-vertices"],
986 * to: ["end-vertices"],
987 * },
988 * ]);
989 * const graphEdgeCollection = graph.edgeCollection("edges");
990 * // Access the underlying EdgeCollection API:
991 * const edgeCollection = graphEdgeCollection.collection;
992 * ```
993 */
994 edgeCollection<T extends Record<string, any> = any>(collection: string | ArangoCollection): GraphEdgeCollection<T>;
995 /**
996 * Fetches all edge collections of this graph from the database and returns
997 * an array of their names.
998 *
999 * See also {@link graph.Graph#edgeCollections}.
1000 *
1001 * @example
1002 * ```js
1003 * const db = new Database();
1004 * const graph = db.graph("some-graph");
1005 * const info = await graph.create([
1006 * {
1007 * collection: "edges",
1008 * from: ["start-vertices"],
1009 * to: ["end-vertices"],
1010 * },
1011 * ]);
1012 * const edgeCollectionNames = await graph.listEdgeCollections();
1013 * // ["edges"]
1014 * ```
1015 */
1016 listEdgeCollections(): Promise<string[]>;
1017 /**
1018 * Fetches all edge collections of this graph from the database and returns
1019 * an array of {@link graph.GraphEdgeCollection} instances.
1020 *
1021 * See also {@link graph.Graph#listEdgeCollections}.
1022 *
1023 * @example
1024 * ```js
1025 * const db = new Database();
1026 * const graph = db.graph("some-graph");
1027 * const info = await graph.create([
1028 * {
1029 * collection: "edges",
1030 * from: ["start-vertices"],
1031 * to: ["end-vertices"],
1032 * },
1033 * ]);
1034 * const graphEdgeCollections = await graph.edgeCollections();
1035 * for (const collection of graphEdgeCollection) {
1036 * console.log(collection.name);
1037 * // "edges"
1038 * }
1039 * ```
1040 */
1041 edgeCollections(): Promise<GraphEdgeCollection[]>;
1042 /**
1043 * Adds an edge definition to this graph.
1044 *
1045 * @param edgeDefinition - Definition of a relation in this graph.
1046 *
1047 * @example
1048 * ```js
1049 * const db = new Database();
1050 * const graph = db.graph("some-graph");
1051 * await graph.addEdgeDefinition({
1052 * collection: "edges",
1053 * from: ["start-vertices"],
1054 * to: ["end-vertices"],
1055 * });
1056 * // The edge definition has been added to the graph
1057 * ```
1058 */
1059 addEdgeDefinition(edgeDefinition: EdgeDefinitionOptions, options?: AddEdgeDefinitionOptions): Promise<GraphInfo>;
1060 /**
1061 * Replaces an edge definition in this graph. The existing edge definition
1062 * for the given edge collection will be overwritten.
1063 *
1064 * @param edgeDefinition - Definition of a relation in this graph.
1065 *
1066 * @example
1067 * ```js
1068 * const db = new Database();
1069 * const graph = db.graph("some-graph");
1070 * const info = await graph.create([
1071 * {
1072 * collection: "edges",
1073 * from: ["start-vertices"],
1074 * to: ["end-vertices"],
1075 * },
1076 * ]);
1077 * await graph.replaceEdgeDefinition({
1078 * collection: "edges",
1079 * from: ["start-vertices"],
1080 * to: ["other-vertices"],
1081 * });
1082 * // The edge definition for "edges" has been replaced
1083 * ```
1084 */
1085 replaceEdgeDefinition(edgeDefinition: EdgeDefinitionOptions, options?: ReplaceEdgeDefinitionOptions): Promise<GraphInfo>;
1086 /**
1087 * Replaces an edge definition in this graph. The existing edge definition
1088 * for the given edge collection will be overwritten.
1089 *
1090 * @param collection - Edge collection for which to replace the definition.
1091 * @param edgeDefinition - Definition of a relation in this graph.
1092 *
1093 * @example
1094 * ```js
1095 * const db = new Database();
1096 * const graph = db.graph("some-graph");
1097 * const info = await graph.create([
1098 * {
1099 * collection: "edges",
1100 * from: ["start-vertices"],
1101 * to: ["end-vertices"],
1102 * },
1103 * ]);
1104 * await graph.replaceEdgeDefinition("edges", {
1105 * collection: "edges",
1106 * from: ["start-vertices"],
1107 * to: ["other-vertices"],
1108 * });
1109 * // The edge definition for "edges" has been replaced
1110 * ```
1111 */
1112 replaceEdgeDefinition(collection: string | ArangoCollection, edgeDefinition: EdgeDefinitionOptions, options?: ReplaceEdgeDefinitionOptions): Promise<GraphInfo>;
1113 /**
1114 * Removes the edge definition for the given edge collection from this graph.
1115 *
1116 * @param collection - Edge collection for which to remove the definition.
1117 * @param dropCollection - If set to `true`, the collection will also be
1118 * deleted from the database.
1119 *
1120 * @example
1121 * ```js
1122 * const db = new Database();
1123 * const graph = db.graph("some-graph");
1124 * const info = await graph.create([
1125 * {
1126 * collection: "edges",
1127 * from: ["start-vertices"],
1128 * to: ["end-vertices"],
1129 * },
1130 * ]);
1131 * await graph.removeEdgeDefinition("edges");
1132 * // The edge definition for "edges" has been replaced
1133 * ```
1134 */
1135 removeEdgeDefinition(collection: string | ArangoCollection, dropCollection?: boolean): Promise<GraphInfo>;
1136}
1137//# sourceMappingURL=graph.d.ts.map
\No newline at end of file