1 | /**
|
2 | * ```ts
|
3 | * import type { Document, Edge } from "arangojs/documents.js";
|
4 | * ```
|
5 | *
|
6 | * The "documents" module provides document/edge related types for TypeScript.
|
7 | *
|
8 | * @packageDocumentation
|
9 | */
|
10 | /**
|
11 | * Common ArangoDB metadata properties of a document.
|
12 | */
|
13 | export type DocumentMetadata = {
|
14 | /**
|
15 | * Key of the document, which uniquely identifies the document within its
|
16 | * collection.
|
17 | */
|
18 | _key: string;
|
19 | /**
|
20 | * Unique ID of the document, which is composed of the collection name
|
21 | * and the document `_key`.
|
22 | */
|
23 | _id: string;
|
24 | /**
|
25 | * Revision of the document data.
|
26 | */
|
27 | _rev: string;
|
28 | };
|
29 | /**
|
30 | * ArangoDB metadata defining the relations of an edge document.
|
31 | */
|
32 | export type EdgeMetadata = {
|
33 | /**
|
34 | * Unique ID of the document that acts as the edge's start vertex.
|
35 | */
|
36 | _from: string;
|
37 | /**
|
38 | * Unique ID of the document that acts as the edge's end vertex.
|
39 | */
|
40 | _to: string;
|
41 | };
|
42 | /**
|
43 | * Type representing an object that can be stored in a collection.
|
44 | */
|
45 | export type DocumentData<T extends Record<string, any> = any> = T & Partial<DocumentMetadata> & Partial<EdgeMetadata>;
|
46 | /**
|
47 | * Type representing an object that can be stored in an edge collection.
|
48 | */
|
49 | export type EdgeData<T extends Record<string, any> = any> = T & Partial<DocumentMetadata> & EdgeMetadata;
|
50 | /**
|
51 | * Type representing a document stored in a collection.
|
52 | */
|
53 | export type Document<T extends Record<string, any> = any> = T & DocumentMetadata & Partial<EdgeMetadata>;
|
54 | /**
|
55 | * Type representing an edge document stored in an edge collection.
|
56 | */
|
57 | export type Edge<T extends Record<string, any> = any> = T & DocumentMetadata & EdgeMetadata;
|
58 | /**
|
59 | * Type representing patch data for a given object type to represent a payload
|
60 | * ArangoDB can apply in a document PATCH request (i.e. a partial update).
|
61 | *
|
62 | * This differs from `Partial` in that it also applies itself to any nested
|
63 | * objects recursively.
|
64 | */
|
65 | export type Patch<T = Record<string, any>> = {
|
66 | [K in keyof T]?: T[K] | Patch<T[K]>;
|
67 | };
|
68 | /**
|
69 | * An object with an ArangoDB document `_id` property.
|
70 | *
|
71 | * See {@link documents.DocumentMetadata}.
|
72 | */
|
73 | export type ObjectWithId = {
|
74 | [key: string]: any;
|
75 | _id: string;
|
76 | };
|
77 | /**
|
78 | * An object with an ArangoDB document `_key` property.
|
79 | *
|
80 | * See {@link documents.DocumentMetadata}.
|
81 | */
|
82 | export type ObjectWithKey = {
|
83 | [key: string]: any;
|
84 | _key: string;
|
85 | };
|
86 | /**
|
87 | * A value that can be used to identify a document within a collection in
|
88 | * arangojs methods, i.e. a partial ArangoDB document or the value of a
|
89 | * document's `_key` or `_id`.
|
90 | *
|
91 | * See {@link documents.DocumentMetadata}.
|
92 | */
|
93 | export type DocumentSelector = ObjectWithId | ObjectWithKey | string;
|
94 | /**
|
95 | * @internal
|
96 | */
|
97 | export declare function _documentHandle(selector: DocumentSelector, collectionName: string, strict?: boolean): string;
|
98 | //# sourceMappingURL=documents.d.ts.map |
\ | No newline at end of file |