1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | import { Analyzer, AnalyzerDescription, CreateAnalyzerOptions } from "./analyzer.js";
|
16 | import { AqlLiteral, AqlQuery } from "./aql.js";
|
17 | import { ArangoCollection, Collection, CollectionMetadata, CollectionType, CreateCollectionOptions, DocumentCollection, EdgeCollection } from "./collection.js";
|
18 | import { ArangoApiResponse, Config, Connection, RequestOptions } from "./connection.js";
|
19 | import { ArrayCursor } from "./cursor.js";
|
20 | import { FoxxManifest } from "./foxx-manifest.js";
|
21 | import { CreateGraphOptions, EdgeDefinitionOptions, Graph, GraphInfo } from "./graph.js";
|
22 | import { Job } from "./job.js";
|
23 | import { ArangojsResponse } from "./lib/request.js";
|
24 | import { Route } from "./route.js";
|
25 | import { Transaction } from "./transaction.js";
|
26 | import { CreateViewOptions, View, ViewDescription } from "./view.js";
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | export declare function isArangoDatabase(database: any): database is Database;
|
33 |
|
34 |
|
35 |
|
36 | export type TransactionCollections = {
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 | exclusive?: (string | ArangoCollection)[] | string | ArangoCollection;
|
43 | |
44 |
|
45 |
|
46 |
|
47 | write?: (string | ArangoCollection)[] | string | ArangoCollection;
|
48 | |
49 |
|
50 |
|
51 |
|
52 | read?: (string | ArangoCollection)[] | string | ArangoCollection;
|
53 | };
|
54 |
|
55 |
|
56 |
|
57 | export type TransactionOptions = {
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | allowImplicit?: boolean;
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 | allowDirtyRead?: boolean;
|
72 | |
73 |
|
74 |
|
75 |
|
76 | waitForSync?: boolean;
|
77 | |
78 |
|
79 |
|
80 |
|
81 | lockTimeout?: number;
|
82 | |
83 |
|
84 |
|
85 | maxTransactionSize?: number;
|
86 | |
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | skipFastLockRound?: boolean;
|
93 | };
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | export type QueryOptions = {
|
100 | |
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | allowDirtyRead?: boolean;
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | allowRetry?: boolean;
|
120 | |
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 | timeout?: number;
|
129 | |
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | retryOnConflict?: number;
|
136 | |
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | count?: boolean;
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | batchSize?: number;
|
152 | |
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 | cache?: boolean;
|
159 | |
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | memoryLimit?: number;
|
168 | |
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 | maxRuntime?: number;
|
176 | |
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 | ttl?: number;
|
183 | |
184 |
|
185 |
|
186 |
|
187 | failOnWarning?: boolean;
|
188 | |
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | profile?: boolean | number;
|
198 | |
199 |
|
200 |
|
201 | stream?: boolean;
|
202 | |
203 |
|
204 |
|
205 | maxWarningsCount?: number;
|
206 | |
207 |
|
208 |
|
209 |
|
210 |
|
211 | fullCount?: boolean;
|
212 | |
213 |
|
214 |
|
215 |
|
216 |
|
217 | fillBlockCache?: boolean;
|
218 | |
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 | optimizer?: {
|
225 | rules: string[];
|
226 | };
|
227 | |
228 |
|
229 |
|
230 |
|
231 | maxPlans?: number;
|
232 | |
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 | maxNodesPerCallstack?: number;
|
239 | |
240 |
|
241 |
|
242 | maxTransactionSize?: number;
|
243 | |
244 |
|
245 |
|
246 |
|
247 | intermediateCommitCount?: number;
|
248 | |
249 |
|
250 |
|
251 |
|
252 | intermediateCommitSize?: number;
|
253 | |
254 |
|
255 |
|
256 |
|
257 |
|
258 | skipInaccessibleCollections?: boolean;
|
259 | |
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 | satelliteSyncWait?: number;
|
267 | };
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | export type ExplainOptions = {
|
274 | |
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 | optimizer?: {
|
281 | rules: string[];
|
282 | };
|
283 | |
284 |
|
285 |
|
286 |
|
287 | maxNumberOfPlans?: number;
|
288 | |
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 | allPlans?: boolean;
|
296 | };
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | export type TransactionDetails = {
|
303 | |
304 |
|
305 |
|
306 | id: string;
|
307 | |
308 |
|
309 |
|
310 | state: "running" | "committed" | "aborted";
|
311 | };
|
312 |
|
313 |
|
314 |
|
315 | export type ExplainPlan = {
|
316 | |
317 |
|
318 |
|
319 | nodes: {
|
320 | [key: string]: any;
|
321 | type: string;
|
322 | id: number;
|
323 | dependencies: number[];
|
324 | estimatedCost: number;
|
325 | estimatedNrItems: number;
|
326 | }[];
|
327 | |
328 |
|
329 |
|
330 | rules: string[];
|
331 | |
332 |
|
333 |
|
334 | collections: {
|
335 | name: string;
|
336 | type: "read" | "write";
|
337 | }[];
|
338 | |
339 |
|
340 |
|
341 | variables: {
|
342 | id: number;
|
343 | name: string;
|
344 | }[];
|
345 | |
346 |
|
347 |
|
348 | estimatedCost: number;
|
349 | |
350 |
|
351 |
|
352 | estimatedNrItems: number;
|
353 | |
354 |
|
355 |
|
356 | isModificationQuery: boolean;
|
357 | };
|
358 |
|
359 |
|
360 |
|
361 | export type ExplainStats = {
|
362 | |
363 |
|
364 |
|
365 | rulesExecuted: number;
|
366 | |
367 |
|
368 |
|
369 | rulesSkipped: number;
|
370 | |
371 |
|
372 |
|
373 | plansCreated: number;
|
374 | |
375 |
|
376 |
|
377 | peakMemoryUsage: number;
|
378 | |
379 |
|
380 |
|
381 | executionTime: number;
|
382 | };
|
383 |
|
384 |
|
385 |
|
386 | export type SingleExplainResult = {
|
387 | |
388 |
|
389 |
|
390 | plan: ExplainPlan;
|
391 | |
392 |
|
393 |
|
394 | cacheable: boolean;
|
395 | |
396 |
|
397 |
|
398 | warnings: {
|
399 | code: number;
|
400 | message: string;
|
401 | }[];
|
402 | |
403 |
|
404 |
|
405 | stats: ExplainStats;
|
406 | };
|
407 |
|
408 |
|
409 |
|
410 | export type MultiExplainResult = {
|
411 | |
412 |
|
413 |
|
414 | plans: ExplainPlan[];
|
415 | |
416 |
|
417 |
|
418 | cacheable: boolean;
|
419 | |
420 |
|
421 |
|
422 | warnings: {
|
423 | code: number;
|
424 | message: string;
|
425 | }[];
|
426 | |
427 |
|
428 |
|
429 | stats: ExplainStats;
|
430 | };
|
431 |
|
432 |
|
433 |
|
434 | export type AstNode = {
|
435 | [key: string]: any;
|
436 | type: string;
|
437 | subNodes: AstNode[];
|
438 | };
|
439 |
|
440 |
|
441 |
|
442 | export type ParseResult = {
|
443 | |
444 |
|
445 |
|
446 | parsed: boolean;
|
447 | |
448 |
|
449 |
|
450 | collections: string[];
|
451 | |
452 |
|
453 |
|
454 | bindVars: string[];
|
455 | |
456 |
|
457 |
|
458 | ast: AstNode[];
|
459 | };
|
460 |
|
461 |
|
462 |
|
463 | export type QueryOptimizerRule = {
|
464 | name: string;
|
465 | flags: {
|
466 | hidden: boolean;
|
467 | clusterOnly: boolean;
|
468 | canBeDisabled: boolean;
|
469 | canCreateAdditionalPlans: boolean;
|
470 | disabledByDefault: boolean;
|
471 | enterpriseOnly: boolean;
|
472 | };
|
473 | };
|
474 |
|
475 |
|
476 |
|
477 | export type QueryTracking = {
|
478 | |
479 |
|
480 |
|
481 | enabled: boolean;
|
482 | |
483 |
|
484 |
|
485 | maxQueryStringLength: number;
|
486 | |
487 |
|
488 |
|
489 | maxSlowQueries: number;
|
490 | |
491 |
|
492 |
|
493 |
|
494 | slowQueryThreshold: number;
|
495 | |
496 |
|
497 |
|
498 | trackBindVars: boolean;
|
499 | |
500 |
|
501 |
|
502 | trackSlowQueries: boolean;
|
503 | };
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 | export type QueryTrackingOptions = {
|
510 | |
511 |
|
512 |
|
513 | enabled?: boolean;
|
514 | |
515 |
|
516 |
|
517 | maxQueryStringLength?: number;
|
518 | |
519 |
|
520 |
|
521 | maxSlowQueries?: number;
|
522 | |
523 |
|
524 |
|
525 |
|
526 | slowQueryThreshold?: number;
|
527 | |
528 |
|
529 |
|
530 | trackBindVars?: boolean;
|
531 | |
532 |
|
533 |
|
534 |
|
535 | trackSlowQueries?: boolean;
|
536 | };
|
537 |
|
538 |
|
539 |
|
540 | export type QueryInfo = {
|
541 | |
542 |
|
543 |
|
544 | id: string;
|
545 | |
546 |
|
547 |
|
548 | database: string;
|
549 | |
550 |
|
551 |
|
552 | user: string;
|
553 | |
554 |
|
555 |
|
556 | query: string;
|
557 | |
558 |
|
559 |
|
560 | bindVars: Record<string, any>;
|
561 | |
562 |
|
563 |
|
564 | started: string;
|
565 | |
566 |
|
567 |
|
568 | runTime: number;
|
569 | |
570 |
|
571 |
|
572 | peakMemoryUsage: number;
|
573 | |
574 |
|
575 |
|
576 | state: "executing" | "finished" | "killed";
|
577 | |
578 |
|
579 |
|
580 | stream: boolean;
|
581 | };
|
582 |
|
583 |
|
584 |
|
585 | export type ClusterImbalanceInfo = {
|
586 | |
587 |
|
588 |
|
589 | leader: {
|
590 | |
591 |
|
592 |
|
593 | weightUsed: number[];
|
594 | |
595 |
|
596 |
|
597 | targetWeight: number[];
|
598 | |
599 |
|
600 |
|
601 | numberShards: number[];
|
602 | |
603 |
|
604 |
|
605 | leaderDupl: number[];
|
606 | |
607 |
|
608 |
|
609 | totalWeight: number;
|
610 | |
611 |
|
612 |
|
613 | imbalance: number;
|
614 | |
615 |
|
616 |
|
617 | totalShards: number;
|
618 | };
|
619 | |
620 |
|
621 |
|
622 | shards: {
|
623 | |
624 |
|
625 |
|
626 | sizeUsed: number[];
|
627 | |
628 |
|
629 |
|
630 | targetSize: number[];
|
631 | |
632 |
|
633 |
|
634 | numberShards: number[];
|
635 | |
636 |
|
637 |
|
638 | totalUsed: number;
|
639 | |
640 |
|
641 |
|
642 | totalShards: number;
|
643 | |
644 |
|
645 |
|
646 | totalShardsFromSystemCollections: number;
|
647 | |
648 |
|
649 |
|
650 | imbalance: number;
|
651 | };
|
652 | };
|
653 |
|
654 |
|
655 |
|
656 | export type ClusterRebalanceState = ClusterImbalanceInfo & {
|
657 | |
658 |
|
659 |
|
660 | pendingMoveShards: number;
|
661 | |
662 |
|
663 |
|
664 | todoMoveShards: number;
|
665 | };
|
666 |
|
667 |
|
668 |
|
669 | export type ClusterRebalanceOptions = {
|
670 | |
671 |
|
672 |
|
673 |
|
674 |
|
675 | maximumNumberOfMoves?: number;
|
676 | |
677 |
|
678 |
|
679 |
|
680 |
|
681 | leaderChanges?: boolean;
|
682 | |
683 |
|
684 |
|
685 |
|
686 |
|
687 | moveLeaders?: boolean;
|
688 | |
689 |
|
690 |
|
691 |
|
692 |
|
693 | moveFollowers?: boolean;
|
694 | |
695 |
|
696 |
|
697 |
|
698 |
|
699 | excludeSystemCollections?: boolean;
|
700 | |
701 |
|
702 |
|
703 | piFactor?: number;
|
704 | |
705 |
|
706 |
|
707 |
|
708 |
|
709 | databasesExcluded?: string[];
|
710 | };
|
711 | export type ClusterRebalanceMove = {
|
712 | |
713 |
|
714 |
|
715 | from: string;
|
716 | |
717 |
|
718 |
|
719 | to: string;
|
720 | |
721 |
|
722 |
|
723 | shard: string;
|
724 | |
725 |
|
726 |
|
727 | collection: number;
|
728 | |
729 |
|
730 |
|
731 | isLeader: boolean;
|
732 | };
|
733 | export type ClusterRebalanceResult = {
|
734 | |
735 |
|
736 |
|
737 | imbalanceBefore: ClusterImbalanceInfo;
|
738 | |
739 |
|
740 |
|
741 | imbalanceAfter: ClusterImbalanceInfo;
|
742 | |
743 |
|
744 |
|
745 | moves: ClusterRebalanceMove[];
|
746 | };
|
747 |
|
748 |
|
749 |
|
750 | export type CreateDatabaseUser = {
|
751 | |
752 |
|
753 |
|
754 | username: string;
|
755 | |
756 |
|
757 |
|
758 |
|
759 |
|
760 | passwd?: string;
|
761 | |
762 |
|
763 |
|
764 |
|
765 |
|
766 | active?: boolean;
|
767 | |
768 |
|
769 |
|
770 | extra?: Record<string, any>;
|
771 | };
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 | export type CreateDatabaseOptions = {
|
778 | |
779 |
|
780 |
|
781 | users?: CreateDatabaseUser[];
|
782 | |
783 |
|
784 |
|
785 |
|
786 | sharding?: "" | "flexible" | "single";
|
787 | |
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 | replicationFactor?: "satellite" | number;
|
795 | |
796 |
|
797 |
|
798 |
|
799 | writeConcern?: number;
|
800 | };
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 | export type DatabaseInfo = {
|
807 | |
808 |
|
809 |
|
810 | name: string;
|
811 | |
812 |
|
813 |
|
814 | id: string;
|
815 | |
816 |
|
817 |
|
818 | path: string;
|
819 | |
820 |
|
821 |
|
822 | isSystem: boolean;
|
823 | |
824 |
|
825 |
|
826 |
|
827 | sharding?: "" | "flexible" | "single";
|
828 | |
829 |
|
830 |
|
831 |
|
832 | replicationFactor?: "satellite" | number;
|
833 | |
834 |
|
835 |
|
836 |
|
837 | writeConcern?: number;
|
838 | };
|
839 |
|
840 |
|
841 |
|
842 | export type VersionInfo = {
|
843 | |
844 |
|
845 |
|
846 | server: string;
|
847 | |
848 |
|
849 |
|
850 | license: "community" | "enterprise";
|
851 | |
852 |
|
853 |
|
854 | version: string;
|
855 | |
856 |
|
857 |
|
858 | details?: {
|
859 | [key: string]: string;
|
860 | };
|
861 | };
|
862 |
|
863 |
|
864 |
|
865 | export type AqlUserFunction = {
|
866 | |
867 |
|
868 |
|
869 | name: string;
|
870 | |
871 |
|
872 |
|
873 | code: string;
|
874 | |
875 |
|
876 |
|
877 |
|
878 |
|
879 | isDeterministic: boolean;
|
880 | };
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 | export type InstallServiceOptions = {
|
887 | |
888 |
|
889 |
|
890 |
|
891 |
|
892 | configuration?: Record<string, any>;
|
893 | |
894 |
|
895 |
|
896 |
|
897 |
|
898 | dependencies?: Record<string, string>;
|
899 | |
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 | development?: boolean;
|
907 | |
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 | legacy?: boolean;
|
915 | |
916 |
|
917 |
|
918 |
|
919 |
|
920 | setup?: boolean;
|
921 | };
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 | export type ReplaceServiceOptions = {
|
928 | |
929 |
|
930 |
|
931 |
|
932 |
|
933 | configuration?: Record<string, any>;
|
934 | |
935 |
|
936 |
|
937 |
|
938 |
|
939 | dependencies?: Record<string, string>;
|
940 | |
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 | development?: boolean;
|
948 | |
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 | legacy?: boolean;
|
956 | |
957 |
|
958 |
|
959 |
|
960 |
|
961 | setup?: boolean;
|
962 | |
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 | teardown?: boolean;
|
969 | |
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 | force?: boolean;
|
976 | };
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 | export type UpgradeServiceOptions = {
|
983 | |
984 |
|
985 |
|
986 |
|
987 |
|
988 | configuration?: Record<string, any>;
|
989 | |
990 |
|
991 |
|
992 |
|
993 |
|
994 | dependencies?: Record<string, string>;
|
995 | |
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 | development?: boolean;
|
1003 | |
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 | legacy?: boolean;
|
1011 | |
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 | setup?: boolean;
|
1017 | |
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 | teardown?: boolean;
|
1024 | |
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 | force?: boolean;
|
1031 | };
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 | export type UninstallServiceOptions = {
|
1038 | |
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 | teardown?: boolean;
|
1045 | |
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 | force?: boolean;
|
1052 | };
|
1053 |
|
1054 |
|
1055 |
|
1056 | export type ServiceSummary = {
|
1057 | |
1058 |
|
1059 |
|
1060 | mount: string;
|
1061 | |
1062 |
|
1063 |
|
1064 | name?: string;
|
1065 | |
1066 |
|
1067 |
|
1068 | version?: string;
|
1069 | |
1070 |
|
1071 |
|
1072 |
|
1073 | provides: Record<string, string>;
|
1074 | |
1075 |
|
1076 |
|
1077 | development: boolean;
|
1078 | |
1079 |
|
1080 |
|
1081 | legacy: boolean;
|
1082 | };
|
1083 |
|
1084 |
|
1085 |
|
1086 | export type ServiceInfo = {
|
1087 | |
1088 |
|
1089 |
|
1090 | mount: string;
|
1091 | |
1092 |
|
1093 |
|
1094 | path: string;
|
1095 | |
1096 |
|
1097 |
|
1098 | name?: string;
|
1099 | |
1100 |
|
1101 |
|
1102 | version?: string;
|
1103 | |
1104 |
|
1105 |
|
1106 | development: boolean;
|
1107 | |
1108 |
|
1109 |
|
1110 | legacy: boolean;
|
1111 | |
1112 |
|
1113 |
|
1114 | manifest: FoxxManifest;
|
1115 | |
1116 |
|
1117 |
|
1118 | checksum: string;
|
1119 | |
1120 |
|
1121 |
|
1122 | options: {
|
1123 | |
1124 |
|
1125 |
|
1126 | configuration: Record<string, any>;
|
1127 | |
1128 |
|
1129 |
|
1130 | dependencies: Record<string, string>;
|
1131 | };
|
1132 | };
|
1133 |
|
1134 |
|
1135 |
|
1136 | export type ServiceConfiguration = {
|
1137 | |
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 | type: "integer" | "boolean" | "string" | "number" | "json" | "password" | "int" | "bool";
|
1146 | |
1147 |
|
1148 |
|
1149 | currentRaw: any;
|
1150 | |
1151 |
|
1152 |
|
1153 |
|
1154 | current: any;
|
1155 | |
1156 |
|
1157 |
|
1158 | title: string;
|
1159 | |
1160 |
|
1161 |
|
1162 | description?: string;
|
1163 | |
1164 |
|
1165 |
|
1166 |
|
1167 | required: boolean;
|
1168 | |
1169 |
|
1170 |
|
1171 | default?: any;
|
1172 | };
|
1173 |
|
1174 |
|
1175 |
|
1176 | export type SingleServiceDependency = {
|
1177 | |
1178 |
|
1179 |
|
1180 | multiple: false;
|
1181 | |
1182 |
|
1183 |
|
1184 | current?: string;
|
1185 | |
1186 |
|
1187 |
|
1188 | title: string;
|
1189 | |
1190 |
|
1191 |
|
1192 | name: string;
|
1193 | |
1194 |
|
1195 |
|
1196 | version: string;
|
1197 | |
1198 |
|
1199 |
|
1200 | description?: string;
|
1201 | |
1202 |
|
1203 |
|
1204 |
|
1205 | required: boolean;
|
1206 | };
|
1207 |
|
1208 |
|
1209 |
|
1210 | export type MultiServiceDependency = {
|
1211 | |
1212 |
|
1213 |
|
1214 | multiple: true;
|
1215 | |
1216 |
|
1217 |
|
1218 | current?: string[];
|
1219 | |
1220 |
|
1221 |
|
1222 | title: string;
|
1223 | |
1224 |
|
1225 |
|
1226 | name: string;
|
1227 | |
1228 |
|
1229 |
|
1230 | version: string;
|
1231 | |
1232 |
|
1233 |
|
1234 | description?: string;
|
1235 | |
1236 |
|
1237 |
|
1238 |
|
1239 | required: boolean;
|
1240 | };
|
1241 |
|
1242 |
|
1243 |
|
1244 | export type ServiceTestStats = {
|
1245 | |
1246 |
|
1247 |
|
1248 | tests: number;
|
1249 | |
1250 |
|
1251 |
|
1252 | passes: number;
|
1253 | |
1254 |
|
1255 |
|
1256 | failures: number;
|
1257 | |
1258 |
|
1259 |
|
1260 | pending: number;
|
1261 | |
1262 |
|
1263 |
|
1264 | duration: number;
|
1265 | };
|
1266 |
|
1267 |
|
1268 |
|
1269 | export type ServiceTestStreamTest = {
|
1270 | title: string;
|
1271 | fullTitle: string;
|
1272 | duration: number;
|
1273 | err?: string;
|
1274 | };
|
1275 |
|
1276 |
|
1277 |
|
1278 | export type ServiceTestStreamReport = (["start", {
|
1279 | total: number;
|
1280 | }] | ["pass", ServiceTestStreamTest] | ["fail", ServiceTestStreamTest] | ["end", ServiceTestStats])[];
|
1281 |
|
1282 |
|
1283 |
|
1284 | export type ServiceTestSuiteTest = {
|
1285 | result: "pending" | "pass" | "fail";
|
1286 | title: string;
|
1287 | duration: number;
|
1288 | err?: any;
|
1289 | };
|
1290 |
|
1291 |
|
1292 |
|
1293 | export type ServiceTestSuite = {
|
1294 | title: string;
|
1295 | suites: ServiceTestSuite[];
|
1296 | tests: ServiceTestSuiteTest[];
|
1297 | };
|
1298 |
|
1299 |
|
1300 |
|
1301 | export type ServiceTestSuiteReport = {
|
1302 | stats: ServiceTestStats;
|
1303 | suites: ServiceTestSuite[];
|
1304 | tests: ServiceTestSuiteTest[];
|
1305 | };
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 | export type ServiceTestXunitTest = ["testcase", {
|
1311 | classname: string;
|
1312 | name: string;
|
1313 | time: number;
|
1314 | }] | [
|
1315 | "testcase",
|
1316 | {
|
1317 | classname: string;
|
1318 | name: string;
|
1319 | time: number;
|
1320 | },
|
1321 | [
|
1322 | "failure",
|
1323 | {
|
1324 | message: string;
|
1325 | type: string;
|
1326 | },
|
1327 | string
|
1328 | ]
|
1329 | ];
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 | export type ServiceTestXunitReport = [
|
1335 | "testsuite",
|
1336 | {
|
1337 | timestamp: number;
|
1338 | tests: number;
|
1339 | errors: number;
|
1340 | failures: number;
|
1341 | skip: number;
|
1342 | time: number;
|
1343 | },
|
1344 | ...ServiceTestXunitTest[]
|
1345 | ];
|
1346 |
|
1347 |
|
1348 |
|
1349 | export type ServiceTestTapReport = string[];
|
1350 |
|
1351 |
|
1352 |
|
1353 | export type ServiceTestDefaultTest = {
|
1354 | title: string;
|
1355 | fullTitle: string;
|
1356 | duration: number;
|
1357 | err?: string;
|
1358 | };
|
1359 |
|
1360 |
|
1361 |
|
1362 | export type ServiceTestDefaultReport = {
|
1363 | stats: ServiceTestStats;
|
1364 | tests: ServiceTestDefaultTest[];
|
1365 | pending: ServiceTestDefaultTest[];
|
1366 | failures: ServiceTestDefaultTest[];
|
1367 | passes: ServiceTestDefaultTest[];
|
1368 | };
|
1369 |
|
1370 |
|
1371 |
|
1372 | export type SwaggerJson = {
|
1373 | [key: string]: any;
|
1374 | info: {
|
1375 | title: string;
|
1376 | description: string;
|
1377 | version: string;
|
1378 | license: string;
|
1379 | };
|
1380 | path: {
|
1381 | [key: string]: any;
|
1382 | };
|
1383 | };
|
1384 |
|
1385 |
|
1386 |
|
1387 | export type AccessLevel = "rw" | "ro" | "none";
|
1388 |
|
1389 |
|
1390 |
|
1391 | export type ArangoUser = {
|
1392 | |
1393 |
|
1394 |
|
1395 | user: string;
|
1396 | |
1397 |
|
1398 |
|
1399 | active: boolean;
|
1400 | |
1401 |
|
1402 |
|
1403 | extra: Record<string, any>;
|
1404 | };
|
1405 |
|
1406 |
|
1407 |
|
1408 | export type CreateUserOptions = {
|
1409 | |
1410 |
|
1411 |
|
1412 | user: string;
|
1413 | |
1414 |
|
1415 |
|
1416 | passwd: string;
|
1417 | |
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 | active?: boolean;
|
1423 | |
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 | extra?: Record<string, any>;
|
1429 | };
|
1430 |
|
1431 |
|
1432 |
|
1433 | export type UserOptions = {
|
1434 | |
1435 |
|
1436 |
|
1437 | passwd: string;
|
1438 | |
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 | active?: boolean;
|
1444 | |
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 | extra?: Record<string, any>;
|
1450 | };
|
1451 |
|
1452 |
|
1453 |
|
1454 | export type UserAccessLevelOptions = {
|
1455 | |
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 | database?: Database | string;
|
1463 | |
1464 |
|
1465 |
|
1466 | collection?: ArangoCollection | string;
|
1467 | };
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 | export type QueueTimeMetrics = {
|
1473 | |
1474 |
|
1475 |
|
1476 | getLatest: () => number | undefined;
|
1477 | |
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 | getValues: () => [number, number][];
|
1483 | |
1484 |
|
1485 |
|
1486 |
|
1487 | getAvg: () => number;
|
1488 | };
|
1489 |
|
1490 |
|
1491 |
|
1492 | export type HotBackupOptions = {
|
1493 | |
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 | allowInconsistent?: boolean;
|
1500 | |
1501 |
|
1502 |
|
1503 |
|
1504 |
|
1505 |
|
1506 |
|
1507 |
|
1508 | force?: boolean;
|
1509 | |
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 | label?: string;
|
1515 | |
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 | timeout?: number;
|
1522 | };
|
1523 |
|
1524 |
|
1525 |
|
1526 | export type HotBackupResult = {
|
1527 | id: string;
|
1528 | potentiallyInconsistent: boolean;
|
1529 | sizeInBytes: number;
|
1530 | datetime: string;
|
1531 | nrDBServers: number;
|
1532 | nrFiles: number;
|
1533 | };
|
1534 |
|
1535 |
|
1536 |
|
1537 | export type HotBackupList = {
|
1538 | server: string;
|
1539 | list: Record<string, HotBackupResult & {
|
1540 | version: string;
|
1541 | keys: any[];
|
1542 | available: boolean;
|
1543 | nrPiecesPresent: number;
|
1544 | countIncludesFilesOnly: boolean;
|
1545 | }>;
|
1546 | };
|
1547 |
|
1548 |
|
1549 |
|
1550 | export declare enum LogLevel {
|
1551 | FATAL = 0,
|
1552 | ERROR = 1,
|
1553 | WARNING = 2,
|
1554 | INFO = 3,
|
1555 | DEBUG = 4
|
1556 | }
|
1557 |
|
1558 |
|
1559 |
|
1560 | export type LogLevelLabel = "FATAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
1561 |
|
1562 |
|
1563 |
|
1564 | export type LogLevelSetting = LogLevelLabel | "DEFAULT";
|
1565 |
|
1566 |
|
1567 |
|
1568 | export type LogSortDirection = "asc" | "desc";
|
1569 |
|
1570 |
|
1571 |
|
1572 | export type LogEntriesOptions = {
|
1573 | |
1574 |
|
1575 |
|
1576 |
|
1577 |
|
1578 | upto?: LogLevel | LogLevelLabel | Lowercase<LogLevelLabel>;
|
1579 | |
1580 |
|
1581 |
|
1582 | level?: LogLevel | LogLevelLabel | Lowercase<LogLevelLabel>;
|
1583 | |
1584 |
|
1585 |
|
1586 |
|
1587 | start?: number;
|
1588 | |
1589 |
|
1590 |
|
1591 | size?: number;
|
1592 | |
1593 |
|
1594 |
|
1595 | offset?: number;
|
1596 | |
1597 |
|
1598 |
|
1599 | search?: string;
|
1600 | |
1601 |
|
1602 |
|
1603 |
|
1604 |
|
1605 |
|
1606 | sort?: LogSortDirection;
|
1607 | };
|
1608 |
|
1609 |
|
1610 |
|
1611 | export type LogMessage = {
|
1612 | id: number;
|
1613 | topic: string;
|
1614 | level: LogLevelLabel;
|
1615 | date: string;
|
1616 | message: string;
|
1617 | };
|
1618 |
|
1619 |
|
1620 |
|
1621 | export type LogEntries = {
|
1622 | totalAmount: number;
|
1623 | lid: number[];
|
1624 | topic: string[];
|
1625 | level: LogLevel[];
|
1626 | timestamp: number[];
|
1627 | text: string[];
|
1628 | };
|
1629 | type TrappedError = {
|
1630 | error: true;
|
1631 | };
|
1632 | type TrappedRequest = {
|
1633 | error?: false;
|
1634 | jobId: string;
|
1635 | onResolve: (res: ArangojsResponse) => void;
|
1636 | onReject: (error: any) => void;
|
1637 | };
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 | export declare class Database {
|
1643 | protected _connection: Connection;
|
1644 | protected _name: string;
|
1645 | protected _analyzers: Map<string, Analyzer>;
|
1646 | protected _collections: Map<string, Collection<any, any>>;
|
1647 | protected _graphs: Map<string, Graph>;
|
1648 | protected _views: Map<string, View>;
|
1649 | protected _trapRequest?: (trapped: TrappedError | TrappedRequest) => void;
|
1650 | |
1651 |
|
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 | constructor(config?: Config);
|
1667 | /**
|
1668 | * Creates a new `Database` instance with its own connection pool.
|
1669 | *
|
1670 | * See also {@link Database#database}.
|
1671 | *
|
1672 | * @param url - Base URL of the ArangoDB server or list of server URLs.
|
1673 | * Equivalent to the `url` option in {@link connection.Config}.
|
1674 | *
|
1675 | * @example
|
1676 | * ```js
|
1677 | * const db = new Database("http://127.0.0.1:8529", "my_database");
|
1678 | * db.useBasicAuth("admin", "hunter2");
|
1679 | * ```
|
1680 | */
|
1681 | constructor(url: string | string[], name?: string);
|
1682 | /**
|
1683 | * @internal
|
1684 | */
|
1685 | constructor(database: Database, name?: string);
|
1686 | /**
|
1687 | * @internal
|
1688 | *
|
1689 | * Indicates that this object represents an ArangoDB database.
|
1690 | */
|
1691 | get isArangoDatabase(): true;
|
1692 | /**
|
1693 | * Name of the ArangoDB database this instance represents.
|
1694 | */
|
1695 | get name(): string;
|
1696 | /**
|
1697 | * Fetches version information from the ArangoDB server.
|
1698 | *
|
1699 | * @param details - If set to `true`, additional information about the
|
1700 | * ArangoDB server will be available as the `details` property.
|
1701 | *
|
1702 | * @example
|
1703 | * ```js
|
1704 | * const db = new Database();
|
1705 | * const version = await db.version();
|
1706 | * // the version object contains the ArangoDB version information.
|
1707 | * // license: "community" or "enterprise"
|
1708 | * // version: ArangoDB version number
|
1709 | * // server: description of the server
|
1710 | * ```
|
1711 | */
|
1712 | version(details?: boolean): Promise<VersionInfo>;
|
1713 | /**
|
1714 | * Retrives the server's current system time in milliseconds with microsecond
|
1715 | * precision.
|
1716 | */
|
1717 | time(): Promise<number>;
|
1718 | /**
|
1719 | * Returns a new {@link route.Route} instance for the given path (relative to the
|
1720 | * database) that can be used to perform arbitrary HTTP requests.
|
1721 | *
|
1722 | * @param path - The database-relative URL of the route. Defaults to the
|
1723 | * database API root.
|
1724 | * @param headers - Default headers that should be sent with each request to
|
1725 | * the route.
|
1726 | *
|
1727 | * @example
|
1728 | * ```js
|
1729 | * const db = new Database();
|
1730 | * const myFoxxService = db.route("my-foxx-service");
|
1731 | * const response = await myFoxxService.post("users", {
|
1732 | * username: "admin",
|
1733 | * password: "hunter2"
|
1734 | * });
|
1735 | * // response.body is the result of
|
1736 | * // POST /_db/_system/my-foxx-service/users
|
1737 | * // with JSON request body '{"username": "admin", "password": "hunter2"}'
|
1738 | * ```
|
1739 | */
|
1740 | route(path?: string, headers?: Headers | Record<string, string>): Route;
|
1741 | /**
|
1742 | * Creates an async job by executing the given callback function. The first
|
1743 | * database request performed by the callback will be marked for asynchronous
|
1744 | * execution and its result will be made available as an async job.
|
1745 | *
|
1746 | * Returns a {@link Job} instance that can be used to retrieve the result
|
1747 | * of the callback function once the request has been executed.
|
1748 | *
|
1749 | * @param callback - Callback function to execute as an async job.
|
1750 | *
|
1751 | * @example
|
1752 | * ```js
|
1753 | * const db = new Database();
|
1754 | * const job = await db.createJob(() => db.collections());
|
1755 | * while (!job.isLoaded) {
|
1756 | * await timeout(1000);
|
1757 | * await job.load();
|
1758 | * }
|
1759 | *
|
1760 | * ```
|
1761 | */
|
1762 | createJob<T>(callback: () => Promise<T>): Promise<Job<T>>;
|
1763 | /**
|
1764 | * @internal
|
1765 | *
|
1766 | * Performs an arbitrary HTTP request against the database.
|
1767 | *
|
1768 | * If `absolutePath` is set to `true`, the database path will not be
|
1769 | * automatically prepended to the `basePath`.
|
1770 | *
|
1771 | * @param T - Return type to use. Defaults to the response object type.
|
1772 | * @param options - Options for this request.
|
1773 | * @param transform - An optional function to transform the low-level
|
1774 | * response object to a more useful return value.
|
1775 | */
|
1776 | request<T = any>(options: RequestOptions & {
|
1777 | absolutePath?: boolean;
|
1778 | }, transform?: (res: ArangojsResponse) => T): Promise<T>;
|
1779 | /**
|
1780 | * @internal
|
1781 | *
|
1782 | * Performs an arbitrary HTTP request against the database.
|
1783 | *
|
1784 | * If `absolutePath` is set to `true`, the database path will not be
|
1785 | * automatically prepended to the `basePath`.
|
1786 | *
|
1787 | * @param options - Options for this request.
|
1788 | * @param transform - If set to `false`, the raw response object will be
|
1789 | * returned.
|
1790 | */
|
1791 | request(options: RequestOptions & {
|
1792 | absolutePath?: boolean;
|
1793 | }, transform: false): Promise<ArangojsResponse>;
|
1794 | /**
|
1795 | * Updates the URL list by requesting a list of all coordinators in the
|
1796 | * cluster and adding any endpoints not initially specified in the
|
1797 | * {@link connection.Config}.
|
1798 | *
|
1799 | * For long-running processes communicating with an ArangoDB cluster it is
|
1800 | * recommended to run this method periodically (e.g. once per hour) to make
|
1801 | * sure new coordinators are picked up correctly and can be used for
|
1802 | * fail-over or load balancing.
|
1803 | *
|
1804 | * @param overwrite - If set to `true`, the existing host list will be
|
1805 | * replaced instead of extended.
|
1806 | *
|
1807 | * @example
|
1808 | * ```js
|
1809 | * const db = new Database();
|
1810 | * const interval = setInterval(
|
1811 | * () => db.acquireHostList(),
|
1812 | * 5 * 60 * 1000
|
1813 | * );
|
1814 | *
|
1815 | *
|
1816 | * clearInterval(interval);
|
1817 | * system.close();
|
1818 | * ```
|
1819 | */
|
1820 | acquireHostList(overwrite?: boolean): Promise<void>;
|
1821 | /**
|
1822 | * Closes all active connections of this database instance.
|
1823 | *
|
1824 | * Can be used to clean up idling connections during longer periods of
|
1825 | * inactivity.
|
1826 | *
|
1827 | * **Note**: This method currently has no effect in the browser version of
|
1828 | * arangojs.
|
1829 | *
|
1830 | * @example
|
1831 | * ```js
|
1832 | * const db = new Database();
|
1833 | * const sessions = db.collection("sessions");
|
1834 | *
|
1835 | * setInterval(async () => {
|
1836 | * await db.query(aql`
|
1837 | * FOR session IN ${sessions}
|
1838 | * FILTER session.expires < DATE_NOW()
|
1839 | * REMOVE session IN ${sessions}
|
1840 | * `);
|
1841 | *
|
1842 | * system.close();
|
1843 | * }, 1000 * 60 * 60);
|
1844 | * ```
|
1845 | */
|
1846 | close(): void;
|
1847 | /**
|
1848 | * Attempts to initiate a clean shutdown of the server.
|
1849 | */
|
1850 | shutdown(): Promise<void>;
|
1851 | /**
|
1852 | * Performs a request against every known coordinator and returns when the
|
1853 | * request has succeeded against every coordinator or the timeout is reached.
|
1854 | *
|
1855 | * **Note**: This method is primarily intended to make database setup easier
|
1856 | * in cluster scenarios and requires all coordinators to be known to arangojs
|
1857 | * before the method is invoked. The method is not useful in single-server or
|
1858 | * leader-follower replication scenarios.
|
1859 | *
|
1860 | * @example
|
1861 | * ```js
|
1862 | * const db = new Database({ loadBalancingStrategy: "ROUND_ROBIN" });
|
1863 | * await system.acquireHostList();
|
1864 | * const analyzer = db.analyzer("my-analyzer");
|
1865 | * await analyzer.create();
|
1866 | * await db.waitForPropagation(
|
1867 | * { path: `/_api/analyzer/${encodeURIComponent(analyzer.name)}` },
|
1868 | * 30000
|
1869 | * );
|
1870 | *
|
1871 | * ```
|
1872 | *
|
1873 | * @param request - Request to perform against each known coordinator.
|
1874 | * @param timeout - Maximum number of milliseconds to wait for propagation.
|
1875 | */
|
1876 | waitForPropagation(request: RequestOptions, timeout?: number): Promise<void>;
|
1877 | /**
|
1878 | * Methods for accessing the server-reported queue times of the mostly
|
1879 | * recently received responses.
|
1880 | */
|
1881 | get queueTime(): QueueTimeMetrics;
|
1882 | /**
|
1883 | * Sets the limit for the number of values of the most recently received
|
1884 | * server-reported queue times that can be accessed using
|
1885 | * {@link Database#queueTime}.
|
1886 | *
|
1887 | * @param responseQueueTimeSamples - Number of values to maintain.
|
1888 | */
|
1889 | setResponseQueueTimeSamples(responseQueueTimeSamples: number): void;
|
1890 | /**
|
1891 | * Updates the underlying connection's `authorization` header to use Basic
|
1892 | * authentication with the given `username` and `password`, then returns
|
1893 | * itself.
|
1894 | *
|
1895 | * @param username - The username to authenticate with.
|
1896 | * @param password - The password to authenticate with.
|
1897 | *
|
1898 | * @example
|
1899 | * ```js
|
1900 | * const db = new Database();
|
1901 | * db.useBasicAuth("admin", "hunter2");
|
1902 | *
|
1903 | * ```
|
1904 | */
|
1905 | useBasicAuth(username?: string, password?: string): this;
|
1906 | /**
|
1907 | * Updates the underlying connection's `authorization` header to use Bearer
|
1908 | * authentication with the given authentication `token`, then returns itself.
|
1909 | *
|
1910 | * @param token - The token to authenticate with.
|
1911 | *
|
1912 | * @example
|
1913 | * ```js
|
1914 | * const db = new Database();
|
1915 | * db.useBearerAuth("keyboardcat");
|
1916 | *
|
1917 | * ```
|
1918 | */
|
1919 | useBearerAuth(token: string): this;
|
1920 | /**
|
1921 | * Validates the given database credentials and exchanges them for an
|
1922 | * authentication token, then uses the authentication token for future
|
1923 | * requests and returns it.
|
1924 | *
|
1925 | * @param username - The username to authenticate with.
|
1926 | * @param password - The password to authenticate with.
|
1927 | *
|
1928 | * @example
|
1929 | * ```js
|
1930 | * const db = new Database();
|
1931 | * await db.login("admin", "hunter2");
|
1932 | *
|
1933 | * ```
|
1934 | */
|
1935 | login(username?: string, password?: string): Promise<string>;
|
1936 | /**
|
1937 | * Attempts to renew the authentication token passed to {@link Database#useBearerAuth}
|
1938 | * or returned and used by {@link Database#login}. If a new authentication
|
1939 | * token is issued, it will be used for future requests and returned.
|
1940 | *
|
1941 | * @example
|
1942 | * ```js
|
1943 | * const db = new Database();
|
1944 | * await db.login("admin", "hunter2");
|
1945 | *
|
1946 | * const newToken = await db.renewAuthToken();
|
1947 | * if (!newToken)
|
1948 | * ```
|
1949 | */
|
1950 | renewAuthToken(): Promise<string | null>;
|
1951 | /**
|
1952 | * Computes the current cluster imbalance.
|
1953 | *
|
1954 | * @example
|
1955 | * ```js
|
1956 | * const db = new Database();
|
1957 | * const imbalance = await db.getClusterImbalance();
|
1958 | * ```
|
1959 | */
|
1960 | getClusterImbalance(): Promise<ClusterRebalanceState>;
|
1961 | /**
|
1962 | * Computes a set of move shard operations to rebalance the cluster.
|
1963 | *
|
1964 | * @example
|
1965 | * ```js
|
1966 | * const db = new Database();
|
1967 | * const result = await db.computerClusterRebalance({
|
1968 | * moveLeaders: true,
|
1969 | * moveFollowers: true
|
1970 | * });
|
1971 | * if (result.moves.length) {
|
1972 | * await db.executeClusterRebalance(result.moves);
|
1973 | * }
|
1974 | * ```
|
1975 | */
|
1976 | computeClusterRebalance(opts: ClusterRebalanceOptions): Promise<ClusterRebalanceResult>;
|
1977 | /**
|
1978 | * Executes the given cluster move shard operations.
|
1979 | *
|
1980 | * @example
|
1981 | * ```js
|
1982 | * const db = new Database();
|
1983 | * const result = await db.computerClusterRebalance({
|
1984 | * moveLeaders: true,
|
1985 | * moveFollowers: true
|
1986 | * });
|
1987 | * if (result.moves.length) {
|
1988 | * await db.executeClusterRebalance(result.moves);
|
1989 | * }
|
1990 | * ```
|
1991 | */
|
1992 | executeClusterRebalance(moves: ClusterRebalanceMove[]): Promise<unknown>;
|
1993 | /**
|
1994 | * Computes a set of move shard operations to rebalance the cluster and
|
1995 | * executes them.
|
1996 | *
|
1997 | * @example
|
1998 | * ```js
|
1999 | * const db = new Database();
|
2000 | * const result = await db.rebalanceCluster({
|
2001 | * moveLeaders: true,
|
2002 | * moveFollowers: true
|
2003 | * });
|
2004 | *
|
2005 | * ```
|
2006 | */
|
2007 | rebalanceCluster(opts: ClusterRebalanceOptions): Promise<ClusterRebalanceResult>;
|
2008 | /**
|
2009 | * Creates a new `Database` instance for the given `databaseName` that
|
2010 | * shares this database's connection pool.
|
2011 | *
|
2012 | * See also {@link Database:constructor}.
|
2013 | *
|
2014 | * @param databaseName - Name of the database.
|
2015 | *
|
2016 | * @example
|
2017 | * ```js
|
2018 | * const systemDb = new Database();
|
2019 | * const myDb = system.database("my_database");
|
2020 | * ```
|
2021 | */
|
2022 | database(databaseName: string): Database;
|
2023 | /**
|
2024 | * Fetches the database description for the active database from the server.
|
2025 | *
|
2026 | * @example
|
2027 | * ```js
|
2028 | * const db = new Database();
|
2029 | * const info = await db.get();
|
2030 | *
|
2031 | * ```
|
2032 | */
|
2033 | get(): Promise<DatabaseInfo>;
|
2034 | /**
|
2035 | * Checks whether the database exists.
|
2036 | *
|
2037 | * @example
|
2038 | * ```js
|
2039 | * const db = new Database();
|
2040 | * const result = await db.exists();
|
2041 | *
|
2042 | * ```
|
2043 | */
|
2044 | exists(): Promise<boolean>;
|
2045 | /**
|
2046 | * Creates a new database with the given `databaseName` with the given
|
2047 | * `options` and returns a `Database` instance for that database.
|
2048 | *
|
2049 | * @param databaseName - Name of the database to create.
|
2050 | * @param options - Options for creating the database.
|
2051 | *
|
2052 | * @example
|
2053 | * ```js
|
2054 | * const db = new Database();
|
2055 | * const info = await db.createDatabase("mydb", {
|
2056 | * users: [{ username: "root" }]
|
2057 | * });
|
2058 | *
|
2059 | * ```
|
2060 | */
|
2061 | createDatabase(databaseName: string, options?: CreateDatabaseOptions): Promise<Database>;
|
2062 | /**
|
2063 | * Creates a new database with the given `databaseName` with the given
|
2064 | * `users` and returns a `Database` instance for that database.
|
2065 | *
|
2066 | * @param databaseName - Name of the database to create.
|
2067 | * @param users - Database users to create with the database.
|
2068 | *
|
2069 | * @example
|
2070 | * ```js
|
2071 | * const db = new Database();
|
2072 | * const info = await db.createDatabase("mydb", [{ username: "root" }]);
|
2073 | *
|
2074 | * ```
|
2075 | */
|
2076 | createDatabase(databaseName: string, users: CreateDatabaseUser[]): Promise<Database>;
|
2077 | /**
|
2078 | * Fetches all databases from the server and returns an array of their names.
|
2079 | *
|
2080 | * See also {@link Database#databases} and
|
2081 | * {@link Database#listUserDatabases}.
|
2082 | *
|
2083 | * @example
|
2084 | * ```js
|
2085 | * const db = new Database();
|
2086 | * const names = await db.listDatabases();
|
2087 | *
|
2088 | * ```
|
2089 | */
|
2090 | listDatabases(): Promise<string[]>;
|
2091 | /**
|
2092 | * Fetches all databases accessible to the active user from the server and
|
2093 | * returns an array of their names.
|
2094 | *
|
2095 | * See also {@link Database#userDatabases} and
|
2096 | * {@link Database#listDatabases}.
|
2097 | *
|
2098 | * @example
|
2099 | * ```js
|
2100 | * const db = new Database();
|
2101 | * const names = await db.listUserDatabases();
|
2102 | *
|
2103 | * ```
|
2104 | */
|
2105 | listUserDatabases(): Promise<string[]>;
|
2106 | /**
|
2107 | * Fetches all databases from the server and returns an array of `Database`
|
2108 | * instances for those databases.
|
2109 | *
|
2110 | * See also {@link Database#listDatabases} and
|
2111 | * {@link Database#userDatabases}.
|
2112 | *
|
2113 | * @example
|
2114 | * ```js
|
2115 | * const db = new Database();
|
2116 | * const names = await db.databases();
|
2117 | *
|
2118 | * ```
|
2119 | */
|
2120 | databases(): Promise<Database[]>;
|
2121 | /**
|
2122 | * Fetches all databases accessible to the active user from the server and
|
2123 | * returns an array of `Database` instances for those databases.
|
2124 | *
|
2125 | * See also {@link Database#listUserDatabases} and
|
2126 | * {@link Database#databases}.
|
2127 | *
|
2128 | * @example
|
2129 | * ```js
|
2130 | * const db = new Database();
|
2131 | * const names = await db.userDatabases();
|
2132 | *
|
2133 | * ```
|
2134 | */
|
2135 | userDatabases(): Promise<Database[]>;
|
2136 | /**
|
2137 | * Deletes the database with the given `databaseName` from the server.
|
2138 | *
|
2139 | * @param databaseName - Name of the database to delete.
|
2140 | *
|
2141 | * @example
|
2142 | * ```js
|
2143 | * const db = new Database();
|
2144 | * await db.dropDatabase("mydb");
|
2145 | *
|
2146 | * ```
|
2147 | */
|
2148 | dropDatabase(databaseName: string): Promise<boolean>;
|
2149 | /**
|
2150 | * Returns a `Collection` instance for the given collection name.
|
2151 | *
|
2152 | * In TypeScript the collection implements both the
|
2153 | * {@link collection.DocumentCollection} and {@link collection.EdgeCollection}
|
2154 | * interfaces and can be cast to either type to enforce a stricter API.
|
2155 | *
|
2156 | * @param T - Type to use for document data. Defaults to `any`.
|
2157 | * @param collectionName - Name of the edge collection.
|
2158 | *
|
2159 | * @example
|
2160 | * ```js
|
2161 | * const db = new Database();
|
2162 | * const collection = db.collection("potatoes");
|
2163 | * ```
|
2164 | *
|
2165 | * @example
|
2166 | * ```ts
|
2167 | * interface Person {
|
2168 | * name: string;
|
2169 | * }
|
2170 | * const db = new Database();
|
2171 | * const persons = db.collection<Person>("persons");
|
2172 | * ```
|
2173 | *
|
2174 | * @example
|
2175 | * ```ts
|
2176 | * interface Person {
|
2177 | * name: string;
|
2178 | * }
|
2179 | * interface Friend {
|
2180 | * startDate: number;
|
2181 | * endDate?: number;
|
2182 | * }
|
2183 | * const db = new Database();
|
2184 | * const documents = db.collection("persons") as DocumentCollection<Person>;
|
2185 | * const edges = db.collection("friends") as EdgeCollection<Friend>;
|
2186 | * ```
|
2187 | */
|
2188 | collection<T extends Record<string, any> = any>(collectionName: string): DocumentCollection<T> & EdgeCollection<T>;
|
2189 | /**
|
2190 | * Creates a new collection with the given `collectionName` and `options`,
|
2191 | * then returns a {@link collection.DocumentCollection} instance for the new collection.
|
2192 | *
|
2193 | * @param T - Type to use for document data. Defaults to `any`.
|
2194 | * @param collectionName - Name of the new collection.
|
2195 | * @param options - Options for creating the collection.
|
2196 | *
|
2197 | * @example
|
2198 | * ```ts
|
2199 | * const db = new Database();
|
2200 | * const documents = db.createCollection("persons");
|
2201 | * ```
|
2202 | *
|
2203 | * @example
|
2204 | * ```ts
|
2205 | * interface Person {
|
2206 | * name: string;
|
2207 | * }
|
2208 | * const db = new Database();
|
2209 | * const documents = db.createCollection<Person>("persons");
|
2210 | * ```
|
2211 | */
|
2212 | createCollection<T extends Record<string, any> = any>(collectionName: string, options?: CreateCollectionOptions & {
|
2213 | type?: CollectionType.DOCUMENT_COLLECTION;
|
2214 | }): Promise<DocumentCollection<T>>;
|
2215 | /**
|
2216 | * Creates a new edge collection with the given `collectionName` and
|
2217 | * `options`, then returns an {@link collection.EdgeCollection} instance for the new
|
2218 | * edge collection.
|
2219 | *
|
2220 | * @param T - Type to use for edge document data. Defaults to `any`.
|
2221 | * @param collectionName - Name of the new collection.
|
2222 | * @param options - Options for creating the collection.
|
2223 | *
|
2224 | * @example
|
2225 | * ```js
|
2226 | * const db = new Database();
|
2227 | * const edges = db.createCollection("friends", {
|
2228 | * type: CollectionType.EDGE_COLLECTION
|
2229 | * });
|
2230 | * ```
|
2231 | *
|
2232 | * @example
|
2233 | * ```ts
|
2234 | * interface Friend {
|
2235 | * startDate: number;
|
2236 | * endDate?: number;
|
2237 | * }
|
2238 | * const db = new Database();
|
2239 | * const edges = db.createCollection<Friend>("friends", {
|
2240 | * type: CollectionType.EDGE_COLLECTION
|
2241 | * });
|
2242 | * ```
|
2243 | */
|
2244 | createCollection<T extends Record<string, any> = any>(collectionName: string, options: CreateCollectionOptions & {
|
2245 | type: CollectionType.EDGE_COLLECTION;
|
2246 | }): Promise<EdgeCollection<T>>;
|
2247 | /**
|
2248 | * Creates a new edge collection with the given `collectionName` and
|
2249 | * `options`, then returns an {@link collection.EdgeCollection} instance for the new
|
2250 | * edge collection.
|
2251 | *
|
2252 | * This is a convenience method for calling {@link Database#createCollection}
|
2253 | * with `options.type` set to `EDGE_COLLECTION`.
|
2254 | *
|
2255 | * @param T - Type to use for edge document data. Defaults to `any`.
|
2256 | * @param collectionName - Name of the new collection.
|
2257 | * @param options - Options for creating the collection.
|
2258 | *
|
2259 | * @example
|
2260 | * ```js
|
2261 | * const db = new Database();
|
2262 | * const edges = db.createEdgeCollection("friends");
|
2263 | * ```
|
2264 | *
|
2265 | * @example
|
2266 | * ```ts
|
2267 | * interface Friend {
|
2268 | * startDate: number;
|
2269 | * endDate?: number;
|
2270 | * }
|
2271 | * const db = new Database();
|
2272 | * const edges = db.createEdgeCollection<Friend>("friends");
|
2273 | * ```
|
2274 | */
|
2275 | createEdgeCollection<T extends Record<string, any> = any>(collectionName: string, options?: CreateCollectionOptions): Promise<EdgeCollection<T>>;
|
2276 | /**
|
2277 | * Renames the collection `collectionName` to `newName`.
|
2278 | *
|
2279 | * Additionally removes any stored `Collection` instance for
|
2280 | * `collectionName` from the `Database` instance's internal cache.
|
2281 | *
|
2282 | * **Note**: Renaming collections may not be supported when ArangoDB is
|
2283 | * running in a cluster configuration.
|
2284 | *
|
2285 | * @param collectionName - Current name of the collection.
|
2286 | * @param newName - The new name of the collection.
|
2287 | */
|
2288 | renameCollection(collectionName: string, newName: string): Promise<ArangoApiResponse<CollectionMetadata>>;
|
2289 | /**
|
2290 | * Fetches all collections from the database and returns an array of
|
2291 | * collection descriptions.
|
2292 | *
|
2293 | * See also {@link Database#collections}.
|
2294 | *
|
2295 | * @param excludeSystem - Whether system collections should be excluded.
|
2296 | *
|
2297 | * @example
|
2298 | * ```js
|
2299 | * const db = new Database();
|
2300 | * const collections = await db.listCollections();
|
2301 | *
|
2302 | *
|
2303 | * ```
|
2304 | *
|
2305 | * @example
|
2306 | * ```js
|
2307 | * const db = new Database();
|
2308 | * const collections = await db.listCollections(false);
|
2309 | *
|
2310 | *
|
2311 | * ```
|
2312 | */
|
2313 | listCollections(excludeSystem?: boolean): Promise<CollectionMetadata[]>;
|
2314 | /**
|
2315 | * Fetches all collections from the database and returns an array of
|
2316 | * `Collection` instances.
|
2317 | *
|
2318 | * In TypeScript these instances implement both the
|
2319 | * {@link collection.DocumentCollection} and {@link collection.EdgeCollection}
|
2320 | * interfaces and can be cast to either type to enforce a stricter API.
|
2321 | *
|
2322 | * See also {@link Database#listCollections}.
|
2323 | *
|
2324 | * @param excludeSystem - Whether system collections should be excluded.
|
2325 | *
|
2326 | * @example
|
2327 | * ```js
|
2328 | * const db = new Database();
|
2329 | * const collections = await db.collections();
|
2330 | *
|
2331 | *
|
2332 | * ```
|
2333 | *
|
2334 | * @example
|
2335 | * ```js
|
2336 | * const db = new Database();
|
2337 | * const collections = await db.collections(false);
|
2338 | *
|
2339 | *
|
2340 | * ```
|
2341 | */
|
2342 | collections(excludeSystem?: boolean): Promise<Array<DocumentCollection & EdgeCollection>>;
|
2343 | /**
|
2344 | * Returns a {@link graph.Graph} instance representing the graph with the given
|
2345 | * `graphName`.
|
2346 | *
|
2347 | * @param graphName - Name of the graph.
|
2348 | *
|
2349 | * @example
|
2350 | * ```js
|
2351 | * const db = new Database();
|
2352 | * const graph = db.graph("some-graph");
|
2353 | * ```
|
2354 | */
|
2355 | graph(graphName: string): Graph;
|
2356 | /**
|
2357 | * Creates a graph with the given `graphName` and `edgeDefinitions`, then
|
2358 | * returns a {@link graph.Graph} instance for the new graph.
|
2359 | *
|
2360 | * @param graphName - Name of the graph to be created.
|
2361 | * @param edgeDefinitions - An array of edge definitions.
|
2362 | * @param options - An object defining the properties of the graph.
|
2363 | */
|
2364 | createGraph(graphName: string, edgeDefinitions: EdgeDefinitionOptions[], options?: CreateGraphOptions): Promise<Graph>;
|
2365 | /**
|
2366 | * Fetches all graphs from the database and returns an array of graph
|
2367 | * descriptions.
|
2368 | *
|
2369 | * See also {@link Database#graphs}.
|
2370 | *
|
2371 | * @example
|
2372 | * ```js
|
2373 | * const db = new Database();
|
2374 | * const graphs = await db.listGraphs();
|
2375 | *
|
2376 | * ```
|
2377 | */
|
2378 | listGraphs(): Promise<GraphInfo[]>;
|
2379 | /**
|
2380 | * Fetches all graphs from the database and returns an array of {@link graph.Graph}
|
2381 | * instances for those graphs.
|
2382 | *
|
2383 | * See also {@link Database#listGraphs}.
|
2384 | *
|
2385 | * @example
|
2386 | * ```js
|
2387 | * const db = new Database();
|
2388 | * const graphs = await db.graphs();
|
2389 | *
|
2390 | * ```
|
2391 | */
|
2392 | graphs(): Promise<Graph[]>;
|
2393 | /**
|
2394 | * Returns a {@link view.View} instance for the given `viewName`.
|
2395 | *
|
2396 | * @param viewName - Name of the ArangoSearch or SearchAlias View.
|
2397 | *
|
2398 | * @example
|
2399 | * ```js
|
2400 | * const db = new Database();
|
2401 | * const view = db.view("potatoes");
|
2402 | * ```
|
2403 | */
|
2404 | view(viewName: string): View;
|
2405 | /**
|
2406 | * Creates a new View with the given `viewName` and `options`, then returns a
|
2407 | * {@link view.View} instance for the new View.
|
2408 | *
|
2409 | * @param viewName - Name of the View.
|
2410 | * @param options - An object defining the properties of the View.
|
2411 | *
|
2412 | * @example
|
2413 | * ```js
|
2414 | * const db = new Database();
|
2415 | * const view = await db.createView("potatoes", { type: "arangosearch" });
|
2416 | *
|
2417 | * ```
|
2418 | */
|
2419 | createView(viewName: string, options: CreateViewOptions): Promise<View>;
|
2420 | /**
|
2421 | * Renames the view `viewName` to `newName`.
|
2422 | *
|
2423 | * Additionally removes any stored {@link view.View} instance for `viewName` from
|
2424 | * the `Database` instance's internal cache.
|
2425 | *
|
2426 | * **Note**: Renaming views may not be supported when ArangoDB is running in
|
2427 | * a cluster configuration.
|
2428 | *
|
2429 | * @param viewName - Current name of the view.
|
2430 | * @param newName - The new name of the view.
|
2431 | */
|
2432 | renameView(viewName: string, newName: string): Promise<ArangoApiResponse<ViewDescription>>;
|
2433 | /**
|
2434 | * Fetches all Views from the database and returns an array of View
|
2435 | * descriptions.
|
2436 | *
|
2437 | * See also {@link Database#views}.
|
2438 | *
|
2439 | * @example
|
2440 | * ```js
|
2441 | * const db = new Database();
|
2442 | *
|
2443 | * const views = await db.listViews();
|
2444 | *
|
2445 | * ```
|
2446 | */
|
2447 | listViews(): Promise<ViewDescription[]>;
|
2448 | /**
|
2449 | * Fetches all Views from the database and returns an array of
|
2450 | * {@link view.View} instances
|
2451 | * for the Views.
|
2452 | *
|
2453 | * See also {@link Database#listViews}.
|
2454 | *
|
2455 | * @example
|
2456 | * ```js
|
2457 | * const db = new Database();
|
2458 | * const views = await db.views();
|
2459 | *
|
2460 | * ```
|
2461 | */
|
2462 | views(): Promise<View[]>;
|
2463 | /**
|
2464 | * Returns an {@link analyzer.Analyzer} instance representing the Analyzer with the
|
2465 | * given `analyzerName`.
|
2466 | *
|
2467 | * @example
|
2468 | * ```js
|
2469 | * const db = new Database();
|
2470 | * const analyzer = db.analyzer("some-analyzer");
|
2471 | * const info = await analyzer.get();
|
2472 | * ```
|
2473 | */
|
2474 | analyzer(analyzerName: string): Analyzer;
|
2475 | /**
|
2476 | * Creates a new Analyzer with the given `analyzerName` and `options`, then
|
2477 | * returns an {@link analyzer.Analyzer} instance for the new Analyzer.
|
2478 | *
|
2479 | * @param analyzerName - Name of the Analyzer.
|
2480 | * @param options - An object defining the properties of the Analyzer.
|
2481 | *
|
2482 | * @example
|
2483 | * ```js
|
2484 | * const db = new Database();
|
2485 | * const analyzer = await db.createAnalyzer("potatoes", { type: "identity" });
|
2486 | *
|
2487 | * ```
|
2488 | */
|
2489 | createAnalyzer(analyzerName: string, options: CreateAnalyzerOptions): Promise<Analyzer>;
|
2490 | /**
|
2491 | * Fetches all Analyzers visible in the database and returns an array of
|
2492 | * Analyzer descriptions.
|
2493 | *
|
2494 | * See also {@link Database#analyzers}.
|
2495 | *
|
2496 | * @example
|
2497 | * ```js
|
2498 | * const db = new Database();
|
2499 | * const analyzers = await db.listAnalyzers();
|
2500 | *
|
2501 | * ```
|
2502 | */
|
2503 | listAnalyzers(): Promise<AnalyzerDescription[]>;
|
2504 | /**
|
2505 | * Fetches all Analyzers visible in the database and returns an array of
|
2506 | * {@link analyzer.Analyzer} instances for those Analyzers.
|
2507 | *
|
2508 | * See also {@link Database#listAnalyzers}.
|
2509 | *
|
2510 | * @example
|
2511 | * ```js
|
2512 | * const db = new Database();
|
2513 | * const analyzers = await db.analyzers();
|
2514 | *
|
2515 | * ```
|
2516 | */
|
2517 | analyzers(): Promise<Analyzer[]>;
|
2518 | /**
|
2519 | * Fetches all ArangoDB users visible to the authenticated user and returns
|
2520 | * an array of user objects.
|
2521 | *
|
2522 | * @example
|
2523 | * ```js
|
2524 | * const db = new Database();
|
2525 | * const users = await db.listUsers();
|
2526 | *
|
2527 | * ```
|
2528 | */
|
2529 | listUsers(): Promise<ArangoUser[]>;
|
2530 | /**
|
2531 | * Fetches the user data of a single ArangoDB user.
|
2532 | *
|
2533 | * @param username - Name of the ArangoDB user to fetch.
|
2534 | *
|
2535 | * @example
|
2536 | * ```js
|
2537 | * const db = new Database();
|
2538 | * const user = await db.getUser("steve");
|
2539 | *
|
2540 | * ```
|
2541 | */
|
2542 | getUser(username: string): Promise<ArangoApiResponse<ArangoUser>>;
|
2543 | /**
|
2544 | * Creates a new ArangoDB user with the given password.
|
2545 | *
|
2546 | * @param username - Name of the ArangoDB user to create.
|
2547 | * @param passwd - Password of the new ArangoDB user.
|
2548 | *
|
2549 | * @example
|
2550 | * ```js
|
2551 | * const db = new Database();
|
2552 | * const user = await db.createUser("steve", "hunter2");
|
2553 | *
|
2554 | * ```
|
2555 | */
|
2556 | createUser(username: string, passwd: string): Promise<ArangoApiResponse<ArangoUser>>;
|
2557 | /**
|
2558 | * Creates a new ArangoDB user with the given options.
|
2559 | *
|
2560 | * @param username - Name of the ArangoDB user to create.
|
2561 | * @param options - Additional options for creating the ArangoDB user.
|
2562 | *
|
2563 | * @example
|
2564 | * ```js
|
2565 | * const db = new Database();
|
2566 | * const user = await db.createUser("steve", { passwd: "hunter2" });
|
2567 | *
|
2568 | * ```
|
2569 | */
|
2570 | createUser(username: string, options: UserOptions): Promise<ArangoApiResponse<ArangoUser>>;
|
2571 | /**
|
2572 | * Sets the password of a given ArangoDB user to the new value.
|
2573 | *
|
2574 | * @param username - Name of the ArangoDB user to change the password for.
|
2575 | * @param passwd - New password for the ArangoDB user.
|
2576 | *
|
2577 | * @example
|
2578 | * ```js
|
2579 | * const db = new Database();
|
2580 | * const user = await db.updateUser("steve", "hunter2");
|
2581 | *
|
2582 | * ```
|
2583 | */
|
2584 | updateUser(username: string, passwd: string): Promise<ArangoApiResponse<ArangoUser>>;
|
2585 | /**
|
2586 | * Updates the ArangoDB user with the new options.
|
2587 | *
|
2588 | * @param username - Name of the ArangoDB user to modify.
|
2589 | * @param options - Options of the ArangoDB user to modify.
|
2590 | *
|
2591 | * @example
|
2592 | * ```js
|
2593 | * const db = new Database();
|
2594 | * const user = await db.updateUser("steve", { active: false });
|
2595 | *
|
2596 | * ```
|
2597 | */
|
2598 | updateUser(username: string, options: Partial<UserOptions>): Promise<ArangoApiResponse<ArangoUser>>;
|
2599 | /**
|
2600 | * Replaces the ArangoDB user's option with the new options.
|
2601 | *
|
2602 | * @param username - Name of the ArangoDB user to modify.
|
2603 | * @param options - New options to replace the user's existing options.
|
2604 | *
|
2605 | * @example
|
2606 | * ```js
|
2607 | * const db = new Database();
|
2608 | * const user = await db.replaceUser("steve", { passwd: "", active: false });
|
2609 | *
|
2610 | * ```
|
2611 | */
|
2612 | replaceUser(username: string, options: UserOptions): Promise<ArangoApiResponse<ArangoUser>>;
|
2613 | /**
|
2614 | * Removes the ArangoDB user with the given username from the server.
|
2615 | *
|
2616 | * @param username - Name of the ArangoDB user to remove.
|
2617 | *
|
2618 | * @example
|
2619 | * ```js
|
2620 | * const db = new Database();
|
2621 | * await db.removeUser("steve");
|
2622 | *
|
2623 | * ```
|
2624 | */
|
2625 | removeUser(username: string): Promise<ArangoApiResponse<Record<string, never>>>;
|
2626 | /**
|
2627 | * Fetches the given ArangoDB user's access level for the database, or the
|
2628 | * given collection in the given database.
|
2629 | *
|
2630 | * @param username - Name of the ArangoDB user to fetch the access level for.
|
2631 | * @param database - Database to fetch the access level for.
|
2632 | * @param collection - Collection to fetch the access level for.
|
2633 | *
|
2634 | * @example
|
2635 | * ```js
|
2636 | * const db = new Database();
|
2637 | * const accessLevel = await db.getUserAccessLevel("steve");
|
2638 | *
|
2639 | *
|
2640 | * ```
|
2641 | *
|
2642 | * @example
|
2643 | * ```js
|
2644 | * const db = new Database();
|
2645 | * const accessLevel = await db.getUserAccessLevel("steve", {
|
2646 | * database: "staging"
|
2647 | * });
|
2648 | *
|
2649 | *
|
2650 | * ```
|
2651 | *
|
2652 | * @example
|
2653 | * ```js
|
2654 | * const db = new Database();
|
2655 | * const accessLevel = await db.getUserAccessLevel("steve", {
|
2656 | * collection: "pokemons"
|
2657 | * });
|
2658 | *
|
2659 | *
|
2660 | * ```
|
2661 | *
|
2662 | * @example
|
2663 | * ```js
|
2664 | * const db = new Database();
|
2665 | * const accessLevel = await db.getUserAccessLevel("steve", {
|
2666 | * database: "staging",
|
2667 | * collection: "pokemons"
|
2668 | * });
|
2669 | *
|
2670 | *
|
2671 | * ```
|
2672 | *
|
2673 | * @example
|
2674 | * ```js
|
2675 | * const db = new Database();
|
2676 | * const staging = db.database("staging");
|
2677 | * const accessLevel = await db.getUserAccessLevel("steve", {
|
2678 | * database: staging
|
2679 | * });
|
2680 | *
|
2681 | *
|
2682 | * ```
|
2683 | *
|
2684 | * @example
|
2685 | * ```js
|
2686 | * const db = new Database();
|
2687 | * const staging = db.database("staging");
|
2688 | * const accessLevel = await db.getUserAccessLevel("steve", {
|
2689 | * collection: staging.collection("pokemons")
|
2690 | * });
|
2691 | *
|
2692 | *
|
2693 | * ```
|
2694 | */
|
2695 | getUserAccessLevel(username: string, { database, collection }: UserAccessLevelOptions): Promise<AccessLevel>;
|
2696 | /**
|
2697 | * Sets the given ArangoDB user's access level for the database, or the
|
2698 | * given collection in the given database.
|
2699 | *
|
2700 | * @param username - Name of the ArangoDB user to set the access level for.
|
2701 | * @param database - Database to set the access level for.
|
2702 | * @param collection - Collection to set the access level for.
|
2703 | * @param grant - Access level to set for the given user.
|
2704 | *
|
2705 | * @example
|
2706 | * ```js
|
2707 | * const db = new Database();
|
2708 | * await db.setUserAccessLevel("steve", { grant: "rw" });
|
2709 | *
|
2710 | * ```
|
2711 | *
|
2712 | * @example
|
2713 | * ```js
|
2714 | * const db = new Database();
|
2715 | * await db.setUserAccessLevel("steve", {
|
2716 | * database: "staging",
|
2717 | * grant: "rw"
|
2718 | * });
|
2719 | *
|
2720 | * ```
|
2721 | *
|
2722 | * @example
|
2723 | * ```js
|
2724 | * const db = new Database();
|
2725 | * await db.setUserAccessLevel("steve", {
|
2726 | * collection: "pokemons",
|
2727 | * grant: "rw"
|
2728 | * });
|
2729 | *
|
2730 | *
|
2731 | * ```
|
2732 | *
|
2733 | * @example
|
2734 | * ```js
|
2735 | * const db = new Database();
|
2736 | * await db.setUserAccessLevel("steve", {
|
2737 | * database: "staging",
|
2738 | * collection: "pokemons",
|
2739 | * grant: "rw"
|
2740 | * });
|
2741 | *
|
2742 | *
|
2743 | * ```
|
2744 | *
|
2745 | * @example
|
2746 | * ```js
|
2747 | * const db = new Database();
|
2748 | * const staging = db.database("staging");
|
2749 | * await db.setUserAccessLevel("steve", {
|
2750 | * database: staging,
|
2751 | * grant: "rw"
|
2752 | * });
|
2753 | *
|
2754 | * ```
|
2755 | *
|
2756 | * @example
|
2757 | * ```js
|
2758 | * const db = new Database();
|
2759 | * const staging = db.database("staging");
|
2760 | * await db.setUserAccessLevel("steve", {
|
2761 | * collection: staging.collection("pokemons"),
|
2762 | * grant: "rw"
|
2763 | * });
|
2764 | *
|
2765 | *
|
2766 | * ```
|
2767 | */
|
2768 | setUserAccessLevel(username: string, { database, collection, grant, }: UserAccessLevelOptions & {
|
2769 | grant: AccessLevel;
|
2770 | }): Promise<ArangoApiResponse<Record<string, AccessLevel>>>;
|
2771 | /**
|
2772 | * Clears the given ArangoDB user's access level for the database, or the
|
2773 | * given collection in the given database.
|
2774 | *
|
2775 | * @param username - Name of the ArangoDB user to clear the access level for.
|
2776 | * @param database - Database to clear the access level for.
|
2777 | * @param collection - Collection to clear the access level for.
|
2778 | *
|
2779 | * @example
|
2780 | * ```js
|
2781 | * const db = new Database();
|
2782 | * await db.clearUserAccessLevel("steve");
|
2783 | *
|
2784 | *
|
2785 | * ```
|
2786 | *
|
2787 | * @example
|
2788 | * ```js
|
2789 | * const db = new Database();
|
2790 | * await db.clearUserAccessLevel("steve", { database: "staging" });
|
2791 | *
|
2792 | *
|
2793 | * ```
|
2794 | *
|
2795 | * @example
|
2796 | * ```js
|
2797 | * const db = new Database();
|
2798 | * await db.clearUserAccessLevel("steve", { collection: "pokemons" });
|
2799 | *
|
2800 | *
|
2801 | * ```
|
2802 | *
|
2803 | * @example
|
2804 | * ```js
|
2805 | * const db = new Database();
|
2806 | * await db.clearUserAccessLevel("steve", {
|
2807 | * database: "staging",
|
2808 | * collection: "pokemons"
|
2809 | * });
|
2810 | *
|
2811 | *
|
2812 | * ```
|
2813 | *
|
2814 | * @example
|
2815 | * ```js
|
2816 | * const db = new Database();
|
2817 | * const staging = db.database("staging");
|
2818 | * await db.clearUserAccessLevel("steve", { database: staging });
|
2819 | *
|
2820 | *
|
2821 | * ```
|
2822 | *
|
2823 | * @example
|
2824 | * ```js
|
2825 | * const db = new Database();
|
2826 | * const staging = db.database("staging");
|
2827 | * await db.clearUserAccessLevel("steve", {
|
2828 | * collection: staging.collection("pokemons")
|
2829 | * });
|
2830 | *
|
2831 | *
|
2832 | * ```
|
2833 | */
|
2834 | clearUserAccessLevel(username: string, { database, collection }: UserAccessLevelOptions): Promise<ArangoApiResponse<Record<string, AccessLevel>>>;
|
2835 | /**
|
2836 | * Fetches an object mapping names of databases to the access level of the
|
2837 | * given ArangoDB user for those databases.
|
2838 | *
|
2839 | * @param username - Name of the ArangoDB user to fetch the access levels for.
|
2840 | * @param full - Whether access levels for collections should be included.
|
2841 | *
|
2842 | * @example
|
2843 | * ```js
|
2844 | * const db = new Database();
|
2845 | * const accessLevels = await db.getUserDatabases("steve");
|
2846 | * for (const [databaseName, accessLevel] of Object.entries(accessLevels)) {
|
2847 | * console.log(`${databaseName}: ${accessLevel}`);
|
2848 | * }
|
2849 | * ```
|
2850 | */
|
2851 | getUserDatabases(username: string, full?: false): Promise<Record<string, AccessLevel>>;
|
2852 | /**
|
2853 | * Fetches an object mapping names of databases to the access level of the
|
2854 | * given ArangoDB user for those databases and the collections within each
|
2855 | * database.
|
2856 | *
|
2857 | * @param username - Name of the ArangoDB user to fetch the access levels for.
|
2858 | * @param full - Whether access levels for collections should be included.
|
2859 | *
|
2860 | * @example
|
2861 | * ```js
|
2862 | * const db = new Database();
|
2863 | * const accessLevels = await db.getUserDatabases("steve", true);
|
2864 | * for (const [databaseName, obj] of Object.entries(accessLevels)) {
|
2865 | * console.log(`${databaseName}: ${obj.permission}`);
|
2866 | * for (const [collectionName, accessLevel] of Object.entries(obj.collections)) {
|
2867 | * console.log(`${databaseName}/${collectionName}: ${accessLevel}`);
|
2868 | * }
|
2869 | * }
|
2870 | * ```
|
2871 | */
|
2872 | getUserDatabases(username: string, full: true): Promise<Record<string, {
|
2873 | permission: AccessLevel;
|
2874 | collections: Record<string, AccessLevel | "undefined">;
|
2875 | }>>;
|
2876 | /**
|
2877 | * Performs a server-side JavaScript transaction and returns its return
|
2878 | * value.
|
2879 | *
|
2880 | * Collections can be specified as collection names (strings) or objects
|
2881 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
2882 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
|
2883 | * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
|
2884 | *
|
2885 | * **Note**: The `action` function will be evaluated and executed on the
|
2886 | * server inside ArangoDB's embedded JavaScript environment and can not
|
2887 | * access any values other than those passed via the `params` option.
|
2888 | *
|
2889 | * See the official ArangoDB documentation for
|
2890 | * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)
|
2891 | * for information about accessing the database from within ArangoDB's
|
2892 | * server-side JavaScript environment.
|
2893 | *
|
2894 | * @param collections - Collections involved in the transaction.
|
2895 | * @param action - A string evaluating to a JavaScript function to be
|
2896 | * executed on the server.
|
2897 | * @param options - Options for the transaction. If `options.allowImplicit`
|
2898 | * is specified, it will be used if `collections.allowImplicit` was not
|
2899 | * specified.
|
2900 | *
|
2901 | * @example
|
2902 | * ```js
|
2903 | * const db = new Database();
|
2904 | *
|
2905 | * const action = `
|
2906 | * function(params) {
|
2907 | * // This code will be executed inside ArangoDB!
|
2908 | * const { query } = require("@arangodb");
|
2909 | * return query\`
|
2910 | * FOR user IN _users
|
2911 | * FILTER user.age > ${params.age}
|
2912 | * RETURN u.user
|
2913 | * \`.toArray();
|
2914 | * }
|
2915 | * `);
|
2916 | *
|
2917 | * const result = await db.executeTransaction({
|
2918 | * read: ["_users"]
|
2919 | * }, action, {
|
2920 | * params: { age: 12 }
|
2921 | * });
|
2922 | *
|
2923 | * ```
|
2924 | */
|
2925 | executeTransaction(collections: TransactionCollections & {
|
2926 | allowImplicit?: boolean;
|
2927 | }, action: string, options?: TransactionOptions & {
|
2928 | params?: any;
|
2929 | }): Promise<any>;
|
2930 | /**
|
2931 | * Performs a server-side transaction and returns its return value.
|
2932 | *
|
2933 | * Collections can be specified as collection names (strings) or objects
|
2934 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
2935 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
|
2936 | * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
|
2937 | *
|
2938 | * **Note**: The `action` function will be evaluated and executed on the
|
2939 | * server inside ArangoDB's embedded JavaScript environment and can not
|
2940 | * access any values other than those passed via the `params` option.
|
2941 | * See the official ArangoDB documentation for
|
2942 | * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)
|
2943 | * for information about accessing the database from within ArangoDB's
|
2944 | * server-side JavaScript environment.
|
2945 | *
|
2946 | * @param collections - Collections that can be read from and written to
|
2947 | * during the transaction.
|
2948 | * @param action - A string evaluating to a JavaScript function to be
|
2949 | * executed on the server.
|
2950 | * @param options - Options for the transaction.
|
2951 | *
|
2952 | * @example
|
2953 | * ```js
|
2954 | * const db = new Database();
|
2955 | *
|
2956 | * const action = `
|
2957 | * function(params) {
|
2958 | * // This code will be executed inside ArangoDB!
|
2959 | * const { query } = require("@arangodb");
|
2960 | * return query\`
|
2961 | * FOR user IN _users
|
2962 | * FILTER user.age > ${params.age}
|
2963 | * RETURN u.user
|
2964 | * \`.toArray();
|
2965 | * }
|
2966 | * `);
|
2967 | *
|
2968 | * const result = await db.executeTransaction(["_users"], action, {
|
2969 | * params: { age: 12 }
|
2970 | * });
|
2971 | *
|
2972 | * ```
|
2973 | */
|
2974 | executeTransaction(collections: (string | ArangoCollection)[], action: string, options?: TransactionOptions & {
|
2975 | params?: any;
|
2976 | }): Promise<any>;
|
2977 | /**
|
2978 | * Performs a server-side transaction and returns its return value.
|
2979 | *
|
2980 | * The Collection can be specified as a collection name (string) or an object
|
2981 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
2982 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
|
2983 | * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
|
2984 | *
|
2985 | * **Note**: The `action` function will be evaluated and executed on the
|
2986 | * server inside ArangoDB's embedded JavaScript environment and can not
|
2987 | * access any values other than those passed via the `params` option.
|
2988 | * See the official ArangoDB documentation for
|
2989 | * [the JavaScript `@arangodb` module](https://www.arangodb.com/docs/stable/appendix-java-script-modules-arango-db.html)
|
2990 | * for information about accessing the database from within ArangoDB's
|
2991 | * server-side JavaScript environment.
|
2992 | *
|
2993 | * @param collection - A collection that can be read from and written to
|
2994 | * during the transaction.
|
2995 | * @param action - A string evaluating to a JavaScript function to be
|
2996 | * executed on the server.
|
2997 | * @param options - Options for the transaction.
|
2998 | *
|
2999 | * @example
|
3000 | * ```js
|
3001 | * const db = new Database();
|
3002 | *
|
3003 | * const action = `
|
3004 | * function(params) {
|
3005 | * // This code will be executed inside ArangoDB!
|
3006 | * const { query } = require("@arangodb");
|
3007 | * return query\`
|
3008 | * FOR user IN _users
|
3009 | * FILTER user.age > ${params.age}
|
3010 | * RETURN u.user
|
3011 | * \`.toArray();
|
3012 | * }
|
3013 | * `);
|
3014 | *
|
3015 | * const result = await db.executeTransaction("_users", action, {
|
3016 | * params: { age: 12 }
|
3017 | * });
|
3018 | *
|
3019 | * ```
|
3020 | */
|
3021 | executeTransaction(collection: string | ArangoCollection, action: string, options?: TransactionOptions & {
|
3022 | params?: any;
|
3023 | }): Promise<any>;
|
3024 | /**
|
3025 | * Returns a {@link transaction.Transaction} instance for an existing streaming
|
3026 | * transaction with the given `id`.
|
3027 | *
|
3028 | * See also {@link Database#beginTransaction}.
|
3029 | *
|
3030 | * @param id - The `id` of an existing stream transaction.
|
3031 | *
|
3032 | * @example
|
3033 | * ```js
|
3034 | * const trx1 = await db.beginTransaction(collections);
|
3035 | * const id = trx1.id;
|
3036 | *
|
3037 | * const trx2 = db.transaction(id);
|
3038 | * await trx2.commit();
|
3039 | * ```
|
3040 | */
|
3041 | transaction(transactionId: string): Transaction;
|
3042 | /**
|
3043 | * Begins a new streaming transaction for the given collections, then returns
|
3044 | * a {@link transaction.Transaction} instance for the transaction.
|
3045 | *
|
3046 | * Collections can be specified as collection names (strings) or objects
|
3047 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
3048 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as
|
3049 | * well as (in TypeScript) {@link collection.DocumentCollection} and
|
3050 | * {@link collection.EdgeCollection}.
|
3051 | *
|
3052 | * @param collections - Collections involved in the transaction.
|
3053 | * @param options - Options for the transaction.
|
3054 | *
|
3055 | * @example
|
3056 | * ```js
|
3057 | * const vertices = db.collection("vertices");
|
3058 | * const edges = db.collection("edges");
|
3059 | * const trx = await db.beginTransaction({
|
3060 | * read: ["vertices"],
|
3061 | * write: [edges]
|
3062 | * });
|
3063 | * const start = await trx.step(() => vertices.document("a"));
|
3064 | * const end = await trx.step(() => vertices.document("b"));
|
3065 | * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));
|
3066 | * await trx.commit();
|
3067 | * ```
|
3068 | */
|
3069 | beginTransaction(collections: TransactionCollections, options?: TransactionOptions): Promise<Transaction>;
|
3070 | /**
|
3071 | * Begins a new streaming transaction for the given collections, then returns
|
3072 | * a {@link transaction.Transaction} instance for the transaction.
|
3073 | *
|
3074 | * Collections can be specified as collection names (strings) or objects
|
3075 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
3076 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
|
3077 | * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
|
3078 | *
|
3079 | * @param collections - Collections that can be read from and written to
|
3080 | * during the transaction.
|
3081 | * @param options - Options for the transaction.
|
3082 | *
|
3083 | * @example
|
3084 | * ```js
|
3085 | * const vertices = db.collection("vertices");
|
3086 | * const edges = db.collection("edges");
|
3087 | * const trx = await db.beginTransaction([
|
3088 | * "vertices",
|
3089 | * edges
|
3090 | * ]);
|
3091 | * const start = await trx.step(() => vertices.document("a"));
|
3092 | * const end = await trx.step(() => vertices.document("b"));
|
3093 | * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));
|
3094 | * await trx.commit();
|
3095 | * ```
|
3096 | */
|
3097 | beginTransaction(collections: (string | ArangoCollection)[], options?: TransactionOptions): Promise<Transaction>;
|
3098 | /**
|
3099 | * Begins a new streaming transaction for the given collections, then returns
|
3100 | * a {@link transaction.Transaction} instance for the transaction.
|
3101 | *
|
3102 | * The Collection can be specified as a collection name (string) or an object
|
3103 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
3104 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
|
3105 | * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
|
3106 | *
|
3107 | * @param collection - A collection that can be read from and written to
|
3108 | * during the transaction.
|
3109 | * @param options - Options for the transaction.
|
3110 | *
|
3111 | * @example
|
3112 | * ```js
|
3113 | * const vertices = db.collection("vertices");
|
3114 | * const start = vertices.document("a");
|
3115 | * const end = vertices.document("b");
|
3116 | * const edges = db.collection("edges");
|
3117 | * const trx = await db.beginTransaction(
|
3118 | * edges
|
3119 | * );
|
3120 | * await trx.step(() => edges.save({ _from: start._id, _to: end._id }));
|
3121 | * await trx.commit();
|
3122 | * ```
|
3123 | */
|
3124 | beginTransaction(collection: string | ArangoCollection, options?: TransactionOptions): Promise<Transaction>;
|
3125 | /**
|
3126 | * Begins and commits a transaction using the given callback. Individual
|
3127 | * requests that are part of the transaction need to be wrapped in the step
|
3128 | * function passed into the callback. If the promise returned by the callback
|
3129 | * is rejected, the transaction will be aborted.
|
3130 | *
|
3131 | * Collections can be specified as collection names (strings) or objects
|
3132 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
3133 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as
|
3134 | * well as (in TypeScript) {@link collection.DocumentCollection} and
|
3135 | * {@link collection.EdgeCollection}.
|
3136 | *
|
3137 | * @param collections - Collections involved in the transaction.
|
3138 | * @param callback - Callback function executing the transaction steps.
|
3139 | * @param options - Options for the transaction.
|
3140 | *
|
3141 | * @example
|
3142 | * ```js
|
3143 | * const vertices = db.collection("vertices");
|
3144 | * const edges = db.collection("edges");
|
3145 | * await db.withTransaction(
|
3146 | * {
|
3147 | * read: ["vertices"],
|
3148 | * write: [edges]
|
3149 | * },
|
3150 | * async (step) => {
|
3151 | * const start = await step(() => vertices.document("a"));
|
3152 | * const end = await step(() => vertices.document("b"));
|
3153 | * await step(() => edges.save({ _from: start._id, _to: end._id }));
|
3154 | * }
|
3155 | * );
|
3156 | * ```
|
3157 | */
|
3158 | withTransaction<T>(collections: TransactionCollections, callback: (step: Transaction["step"]) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
3159 | /**
|
3160 | * Begins and commits a transaction using the given callback. Individual
|
3161 | * requests that are part of the transaction need to be wrapped in the step
|
3162 | * function passed into the callback. If the promise returned by the callback
|
3163 | * is rejected, the transaction will be aborted.
|
3164 | *
|
3165 | * Collections can be specified as collection names (strings) or objects
|
3166 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
3167 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
|
3168 | * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
|
3169 | *
|
3170 | * @param collections - Collections that can be read from and written to
|
3171 | * during the transaction.
|
3172 | * @param callback - Callback function executing the transaction steps.
|
3173 | * @param options - Options for the transaction.
|
3174 | *
|
3175 | * @example
|
3176 | * ```js
|
3177 | * const vertices = db.collection("vertices");
|
3178 | * const edges = db.collection("edges");
|
3179 | * await db.withTransaction(
|
3180 | * [
|
3181 | * "vertices",
|
3182 | * edges,
|
3183 | * ],
|
3184 | * async (step) => {
|
3185 | * const start = await step(() => vertices.document("a"));
|
3186 | * const end = await step(() => vertices.document("b"));
|
3187 | * await step(() => edges.save({ _from: start._id, _to: end._id }));
|
3188 | * }
|
3189 | * );
|
3190 | * ```
|
3191 | */
|
3192 | withTransaction<T>(collections: (string | ArangoCollection)[], callback: (step: Transaction["step"]) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
3193 | /**
|
3194 | * Begins and commits a transaction using the given callback. Individual
|
3195 | * requests that are part of the transaction need to be wrapped in the step
|
3196 | * function passed into the callback. If the promise returned by the callback
|
3197 | * is rejected, the transaction will be aborted.
|
3198 | *
|
3199 | * The Collection can be specified as a collection name (string) or an object
|
3200 | * implementing the {@link collection.ArangoCollection} interface: `Collection`,
|
3201 | * {@link graph.GraphVertexCollection}, {@link graph.GraphEdgeCollection} as well as
|
3202 | * (in TypeScript) {@link collection.DocumentCollection} and {@link collection.EdgeCollection}.
|
3203 | *
|
3204 | * @param collection - A collection that can be read from and written to
|
3205 | * during the transaction.
|
3206 | * @param callback - Callback function executing the transaction steps.
|
3207 | * @param options - Options for the transaction.
|
3208 | *
|
3209 | * @example
|
3210 | * ```js
|
3211 | * const vertices = db.collection("vertices");
|
3212 | * const start = vertices.document("a");
|
3213 | * const end = vertices.document("b");
|
3214 | * const edges = db.collection("edges");
|
3215 | * await db.withTransaction(
|
3216 | * edges,
|
3217 | * async (step) => {
|
3218 | * await step(() => edges.save({ _from: start._id, _to: end._id }));
|
3219 | * }
|
3220 | * );
|
3221 | * ```
|
3222 | */
|
3223 | withTransaction<T>(collection: string | ArangoCollection, callback: (step: Transaction["step"]) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
3224 | /**
|
3225 | * Fetches all active transactions from the database and returns an array of
|
3226 | * transaction descriptions.
|
3227 | *
|
3228 | * See also {@link Database#transactions}.
|
3229 | *
|
3230 | * @example
|
3231 | * ```js
|
3232 | * const db = new Database();
|
3233 | * const transactions = await db.listTransactions();
|
3234 | *
|
3235 | * ```
|
3236 | */
|
3237 | listTransactions(): Promise<TransactionDetails[]>;
|
3238 | /**
|
3239 | * Fetches all active transactions from the database and returns an array of
|
3240 | * {@link transaction.Transaction} instances for those transactions.
|
3241 | *
|
3242 | * See also {@link Database#listTransactions}.
|
3243 | *
|
3244 | * @example
|
3245 | * ```js
|
3246 | * const db = new Database();
|
3247 | * const transactions = await db.transactions();
|
3248 | *
|
3249 | * ```
|
3250 | */
|
3251 | transactions(): Promise<Transaction[]>;
|
3252 | /**
|
3253 | * Performs a database query using the given `query`, then returns a new
|
3254 | * {@link cursor.ArrayCursor} instance for the result set.
|
3255 | *
|
3256 | * See the {@link aql!aql} template string handler for information about how
|
3257 | * to create a query string without manually defining bind parameters nor
|
3258 | * having to worry about escaping variables.
|
3259 | *
|
3260 | * **Note**: When executing a query in a streaming transaction using the
|
3261 | * `step` method, the resulting cursor will be bound to that transaction and
|
3262 | * you do not need to use the `step` method to consume it.
|
3263 | *
|
3264 | * @param query - An object containing an AQL query string and bind
|
3265 | * parameters, e.g. the object returned from an {@link aql!aql} template string.
|
3266 | * @param options - Options for the query execution.
|
3267 | *
|
3268 | * @example
|
3269 | * ```js
|
3270 | * const db = new Database();
|
3271 | * const active = true;
|
3272 | * const Users = db.collection("_users");
|
3273 | *
|
3274 | *
|
3275 | *
|
3276 | *
|
3277 | * const cursor = await db.query(aql`
|
3278 | * FOR u IN ${Users}
|
3279 | * FILTER u.authData.active == ${active}
|
3280 | * RETURN u.user
|
3281 | * `);
|
3282 | *
|
3283 | * ```
|
3284 | *
|
3285 | * @example
|
3286 | * ```js
|
3287 | * const db = new Database();
|
3288 | * const active = true;
|
3289 | * const Users = db.collection("_users");
|
3290 | *
|
3291 | *
|
3292 | * const cursor = await db.query({
|
3293 | * query: `
|
3294 | * FOR u IN @@users
|
3295 | * FILTER u.authData.active == @active
|
3296 | * RETURN u.user
|
3297 | * `,
|
3298 | * bindVars: { active: active, "@users": Users.name }
|
3299 | * });
|
3300 | * ```
|
3301 | */
|
3302 | query<T = any>(query: AqlQuery<T>, options?: QueryOptions): Promise<ArrayCursor<T>>;
|
3303 | /**
|
3304 | * Performs a database query using the given `query` and `bindVars`, then
|
3305 | * returns a new {@link cursor.ArrayCursor} instance for the result set.
|
3306 | *
|
3307 | * See the {@link aql!aql} template string handler for a safer and easier
|
3308 | * alternative to passing strings directly.
|
3309 | *
|
3310 | * **Note**: When executing a query in a streaming transaction using the
|
3311 | * `step` method, the resulting cursor will be bound to that transaction and
|
3312 | * you do not need to use the `step` method to consume it.
|
3313 | *
|
3314 | * @param query - An AQL query string.
|
3315 | * @param bindVars - An object defining bind parameters for the query.
|
3316 | * @param options - Options for the query execution.
|
3317 | *
|
3318 | * @example
|
3319 | * ```js
|
3320 | * const db = new Database();
|
3321 | * const active = true;
|
3322 | * const Users = db.collection("_users");
|
3323 | *
|
3324 | * const cursor = await db.query(
|
3325 | *
|
3326 | * `
|
3327 | * FOR u IN @@users
|
3328 | * FILTER u.authData.active == @active
|
3329 | * RETURN u.user
|
3330 | * `,
|
3331 | * { active: active, "@users": Users.name }
|
3332 | * );
|
3333 | * ```
|
3334 | *
|
3335 | * @example
|
3336 | * ```js
|
3337 | * const db = new Database();
|
3338 | * const active = true;
|
3339 | * const Users = db.collection("_users");
|
3340 | *
|
3341 | * const cursor = await db.query(
|
3342 | *
|
3343 | * aql.literal(`
|
3344 | * FOR u IN @@users
|
3345 | * FILTER u.authData.active == @active
|
3346 | * RETURN u.user
|
3347 | * `),
|
3348 | * { active: active, "@users": Users.name }
|
3349 | * );
|
3350 | * ```
|
3351 | */
|
3352 | query<T = any>(query: string | AqlLiteral, bindVars?: Record<string, any>, options?: QueryOptions): Promise<ArrayCursor<T>>;
|
3353 | /**
|
3354 | * Explains a database query using the given `query`.
|
3355 | *
|
3356 | * See the {@link aql!aql} template string handler for information about how
|
3357 | * to create a query string without manually defining bind parameters nor
|
3358 | * having to worry about escaping variables.
|
3359 | *
|
3360 | * @param query - An object containing an AQL query string and bind
|
3361 | * parameters, e.g. the object returned from an {@link aql!aql} template string.
|
3362 | * @param options - Options for explaining the query.
|
3363 | *
|
3364 | * @example
|
3365 | * ```js
|
3366 | * const db = new Database();
|
3367 | * const collection = db.collection("some-collection");
|
3368 | * const explanation = await db.explain(aql`
|
3369 | * FOR doc IN ${collection}
|
3370 | * FILTER doc.flavor == "strawberry"
|
3371 | * RETURN doc._key
|
3372 | * `);
|
3373 | * ```
|
3374 | */
|
3375 | explain(query: AqlQuery, options?: ExplainOptions & {
|
3376 | allPlans?: false;
|
3377 | }): Promise<ArangoApiResponse<SingleExplainResult>>;
|
3378 | /**
|
3379 | * Explains a database query using the given `query`.
|
3380 | *
|
3381 | * See the {@link aql!aql} template string handler for information about how
|
3382 | * to create a query string without manually defining bind parameters nor
|
3383 | * having to worry about escaping variables.
|
3384 | *
|
3385 | * @param query - An object containing an AQL query string and bind
|
3386 | * parameters, e.g. the object returned from an {@link aql!aql} template string.
|
3387 | * @param options - Options for explaining the query.
|
3388 | *
|
3389 | * @example
|
3390 | * ```js
|
3391 | * const db = new Database();
|
3392 | * const collection = db.collection("some-collection");
|
3393 | * const explanation = await db.explain(
|
3394 | * aql`
|
3395 | * FOR doc IN ${collection}
|
3396 | * FILTER doc.flavor == "strawberry"
|
3397 | * RETURN doc._key
|
3398 | * `,
|
3399 | * { allPlans: true }
|
3400 | * );
|
3401 | * ```
|
3402 | */
|
3403 | explain(query: AqlQuery, options?: ExplainOptions & {
|
3404 | allPlans: true;
|
3405 | }): Promise<ArangoApiResponse<MultiExplainResult>>;
|
3406 | /**
|
3407 | * Explains a database query using the given `query` and `bindVars`.
|
3408 | *
|
3409 | * See the {@link aql!aql} template string handler for a safer and easier
|
3410 | * alternative to passing strings directly.
|
3411 | *
|
3412 | * @param query - An AQL query string.
|
3413 | * @param bindVars - An object defining bind parameters for the query.
|
3414 | * @param options - Options for explaining the query.
|
3415 | *
|
3416 | * @example
|
3417 | * ```js
|
3418 | * const db = new Database();
|
3419 | * const collection = db.collection("some-collection");
|
3420 | * const explanation = await db.explain(
|
3421 | * `
|
3422 | * FOR doc IN @@collection
|
3423 | * FILTER doc.flavor == "strawberry"
|
3424 | * RETURN doc._key
|
3425 | * `,
|
3426 | * { "@collection": collection.name }
|
3427 | * );
|
3428 | * ```
|
3429 | */
|
3430 | explain(query: string | AqlLiteral, bindVars?: Record<string, any>, options?: ExplainOptions & {
|
3431 | allPlans?: false;
|
3432 | }): Promise<ArangoApiResponse<SingleExplainResult>>;
|
3433 | /**
|
3434 | * Explains a database query using the given `query` and `bindVars`.
|
3435 | *
|
3436 | * See the {@link aql!aql} template string handler for a safer and easier
|
3437 | * alternative to passing strings directly.
|
3438 | *
|
3439 | * @param query - An AQL query string.
|
3440 | * @param bindVars - An object defining bind parameters for the query.
|
3441 | * @param options - Options for explaining the query.
|
3442 | *
|
3443 | * @example
|
3444 | * ```js
|
3445 | * const db = new Database();
|
3446 | * const collection = db.collection("some-collection");
|
3447 | * const explanation = await db.explain(
|
3448 | * `
|
3449 | * FOR doc IN @@collection
|
3450 | * FILTER doc.flavor == "strawberry"
|
3451 | * RETURN doc._key
|
3452 | * `,
|
3453 | * { "@collection": collection.name },
|
3454 | * { allPlans: true }
|
3455 | * );
|
3456 | * ```
|
3457 | */
|
3458 | explain(query: string | AqlLiteral, bindVars?: Record<string, any>, options?: ExplainOptions & {
|
3459 | allPlans: true;
|
3460 | }): Promise<ArangoApiResponse<MultiExplainResult>>;
|
3461 | /**
|
3462 | * Parses the given query and returns the result.
|
3463 | *
|
3464 | * See the {@link aql!aql} template string handler for information about how
|
3465 | * to create a query string without manually defining bind parameters nor
|
3466 | * having to worry about escaping variables.
|
3467 | *
|
3468 | * @param query - An AQL query string or an object containing an AQL query
|
3469 | * string and bind parameters, e.g. the object returned from an {@link aql!aql}
|
3470 | * template string.
|
3471 | *
|
3472 | * @example
|
3473 | * ```js
|
3474 | * const db = new Database();
|
3475 | * const collection = db.collection("some-collection");
|
3476 | * const ast = await db.parse(aql`
|
3477 | * FOR doc IN ${collection}
|
3478 | * FILTER doc.flavor == "strawberry"
|
3479 | * RETURN doc._key
|
3480 | * `);
|
3481 | * ```
|
3482 | |