This repository was archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
81 lines (72 loc) · 2.45 KB
/
types.ts
File metadata and controls
81 lines (72 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import type { MongoDBRequest } from "./mod.ts";
/**
* Represents the configuration settings for connecting to a MongoDB database.
* This configuration includes necessary details such as the base URL, data source,
* database name, and API key.
*/
export interface DatabaseConfig {
/**
* The base URL of the MongoDB Data API endpoint.
* This URL serves as the root for all API requests.
* @example "https://data.mongodb-api.com/app/data-xxxx/endpoint/data/v1"
*/
baseUrl: string;
/**
* The data source name for the MongoDB cluster.
* This is typically the name of the MongoDB Atlas cluster.
* @example "Cluster0"
*/
dataSource: string;
/**
* The name of the specific database to connect to.
* This specifies which database within the cluster the operations should target.
* @example "myDatabase"
*/
database: string;
/**
* The API key used for authenticating requests to the MongoDB Data API.
* This key should be kept secure and not shared publicly.
* @example "your-api-key"
*/
apiKey: string;
}
/**
* Represents a MongoDB document with a unique identifier.
* The `_id` field is a string that uniquely identifies the document.
*/
export type Document = {
/**
* The unique identifier for the document.
* This is typically a string representation of an ObjectId.
* @example "507f1f77bcf86cd799439011"
*/
_id: string;
};
/**
* Represents a query object used in MongoDB operations.
* This is a generic record type where keys are strings and values can be of any type.
* It is used to specify the criteria for querying, updating, or deleting documents.
*/
export type Query = Record<string, unknown>;
/**
* Represents a set of HTTP headers used in a MongoDB request.
* This type is a record where each key is a header name and the value is the header value.
* It allows for the specification of additional headers, such as authentication tokens or custom metadata,
* to be sent along with the request.
*/
export type Headers = Record<string, string>;
/**
* Represents the basic set of endpoint paths available in the MongoDB Data API.
* These endpoints correspond to common database operations such as finding,
* inserting, updating, and deleting documents.
*/
export type BasicEndpoints =
| "/find"
| "/findOne"
| "/insertOne"
| "/insertMany"
| "/updateOne"
| "/updateMany"
| "/deleteOne"
| "/deleteMany";
export type SendDBRequestFunction = <T>(request: MongoDBRequest) => Promise<T>;