@tmlmobilidade/interfaces 20250628.333.59 → 20250628.926.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/mongo-collection.d.ts +10 -14
- package/dist/src/mongo-collection.js +14 -14
- package/package.json +1 -1
|
@@ -9,7 +9,6 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
9
9
|
protected updateSchema: null | z.ZodSchema;
|
|
10
10
|
/**
|
|
11
11
|
* Gets all documents in the collection.
|
|
12
|
-
*
|
|
13
12
|
* @returns A promise that resolves to an array of all documents
|
|
14
13
|
*/
|
|
15
14
|
all(): Promise<WithId<T>[]>;
|
|
@@ -21,28 +20,24 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
21
20
|
connect(options?: MongoClientOptions): Promise<void>;
|
|
22
21
|
/**
|
|
23
22
|
* Counts documents matching the filter criteria.
|
|
24
|
-
*
|
|
25
23
|
* @param filter - The filter criteria to match documents
|
|
26
24
|
* @returns A promise that resolves to the count of matching documents
|
|
27
25
|
*/
|
|
28
26
|
count(filter?: Filter<T>): Promise<number>;
|
|
29
27
|
/**
|
|
30
28
|
* Deletes a single document by its ID.
|
|
31
|
-
*
|
|
32
29
|
* @param id - The ID of the document to delete
|
|
33
30
|
* @returns A promise that resolves to the result of the delete operation
|
|
34
31
|
*/
|
|
35
32
|
deleteById(id: string, options?: DeleteOptions): Promise<DeleteResult>;
|
|
36
33
|
/**
|
|
37
34
|
* Deletes multiple documents matching the filter criteria.
|
|
38
|
-
*
|
|
39
35
|
* @param filter - The filter criteria to match documents to delete
|
|
40
36
|
* @returns A promise that resolves to the result of the delete operation
|
|
41
37
|
*/
|
|
42
38
|
deleteMany(filter: Filter<T>): Promise<DeleteResult>;
|
|
43
39
|
/**
|
|
44
40
|
* Deletes a single document matching the filter criteria.
|
|
45
|
-
*
|
|
46
41
|
* @param filter - The filter criteria to match the document to delete
|
|
47
42
|
* @returns A promise that resolves to the result of the delete operation
|
|
48
43
|
*/
|
|
@@ -53,21 +48,24 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
53
48
|
disconnect(): Promise<void>;
|
|
54
49
|
/**
|
|
55
50
|
* Finds all distinct values for a key in the collection.
|
|
56
|
-
*
|
|
57
51
|
* @param key - The key to find distinct values for
|
|
58
52
|
* @returns A promise that resolves to an array of distinct values for the given key
|
|
59
53
|
*/
|
|
60
54
|
distinct<K extends keyof T>(key: K): Promise<T[K][]>;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if a document with the given ID exists in the collection.
|
|
57
|
+
* @param id The ID of the document to check for existence.
|
|
58
|
+
* @returns A promise that resolves to true if the document exists, false otherwise.
|
|
59
|
+
*/
|
|
60
|
+
exists<K extends keyof T>(key: K, value: T[K]): Promise<boolean>;
|
|
61
61
|
/**
|
|
62
62
|
* Finds a document by its ID.
|
|
63
|
-
*
|
|
64
63
|
* @param id - The ID of the document to find
|
|
65
64
|
* @returns A promise that resolves to the matching document or null if not found
|
|
66
65
|
*/
|
|
67
66
|
findById(id: string, options?: FindOptions): Promise<null | WithId<T>>;
|
|
68
67
|
/**
|
|
69
68
|
* Finds multiple documents matching the filter criteria with optional pagination and sorting.
|
|
70
|
-
*
|
|
71
69
|
* @param filter - (Optional) filter criteria to match documents
|
|
72
70
|
* @param perPage - (Optional) number of documents per page for pagination
|
|
73
71
|
* @param page - (Optional) page number for pagination
|
|
@@ -77,21 +75,22 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
77
75
|
findMany(filter?: Filter<T>, perPage?: number, page?: number, sort?: Sort): Promise<WithId<T>[]>;
|
|
78
76
|
/**
|
|
79
77
|
* Finds a single document matching the filter criteria.
|
|
80
|
-
*
|
|
81
78
|
* @param filter - The filter criteria to match the document
|
|
82
79
|
* @returns A promise that resolves to the matching document or null if not found
|
|
83
80
|
*/
|
|
84
81
|
findOne(filter: Filter<T>): Promise<null | WithId<T>>;
|
|
85
82
|
/**
|
|
86
83
|
* Gets the MongoDB collection instance.
|
|
87
|
-
*
|
|
88
84
|
* @returns The MongoDB collection instance
|
|
89
85
|
*/
|
|
90
86
|
getCollection(): Promise<Collection<T>>;
|
|
87
|
+
/**
|
|
88
|
+
* Gets the MongoDB connector instance.
|
|
89
|
+
* @returns The MongoDB connector instance
|
|
90
|
+
*/
|
|
91
91
|
getMongoConnector(): MongoConnector;
|
|
92
92
|
/**
|
|
93
93
|
* Inserts a single document into the collection.
|
|
94
|
-
*
|
|
95
94
|
* @param doc - The document to insert
|
|
96
95
|
* @param options - The options for the insert operation
|
|
97
96
|
* @returns A promise that resolves to the result of the insert operation
|
|
@@ -106,7 +105,6 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
106
105
|
}): Promise<InsertOneResult<T>>;
|
|
107
106
|
/**
|
|
108
107
|
* Updates a single document matching the filter criteria.
|
|
109
|
-
*
|
|
110
108
|
* @param filter - The filter criteria to match the document to update
|
|
111
109
|
* @param updateFields - The fields to update in the document
|
|
112
110
|
* @param options - The options for the update operation
|
|
@@ -115,7 +113,6 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
115
113
|
updateById(id: string, updateFields: TUpdate, options?: UpdateOptions): Promise<UpdateResult>;
|
|
116
114
|
/**
|
|
117
115
|
* Updates multiple documents matching the filter criteria.
|
|
118
|
-
*
|
|
119
116
|
* @param filter - The filter criteria to match documents to update
|
|
120
117
|
* @param updateFields - The fields to update in the documents
|
|
121
118
|
* @param options - The options for the update operation
|
|
@@ -124,7 +121,6 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
124
121
|
updateMany(filter: Filter<T>, updateFields: TUpdate, options?: UpdateOptions): Promise<UpdateResult<T>>;
|
|
125
122
|
/**
|
|
126
123
|
* Updates a single document matching the filter criteria.
|
|
127
|
-
*
|
|
128
124
|
* @param filter - The filter criteria to match the document to update
|
|
129
125
|
* @param updateFields - The fields to update in the document
|
|
130
126
|
* @param options - The options for the update operation
|
|
@@ -10,7 +10,6 @@ export class MongoCollectionClass {
|
|
|
10
10
|
updateSchema = null;
|
|
11
11
|
/**
|
|
12
12
|
* Gets all documents in the collection.
|
|
13
|
-
*
|
|
14
13
|
* @returns A promise that resolves to an array of all documents
|
|
15
14
|
*/
|
|
16
15
|
async all() {
|
|
@@ -45,7 +44,6 @@ export class MongoCollectionClass {
|
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
47
46
|
* Counts documents matching the filter criteria.
|
|
48
|
-
*
|
|
49
47
|
* @param filter - The filter criteria to match documents
|
|
50
48
|
* @returns A promise that resolves to the count of matching documents
|
|
51
49
|
*/
|
|
@@ -54,7 +52,6 @@ export class MongoCollectionClass {
|
|
|
54
52
|
}
|
|
55
53
|
/**
|
|
56
54
|
* Deletes a single document by its ID.
|
|
57
|
-
*
|
|
58
55
|
* @param id - The ID of the document to delete
|
|
59
56
|
* @returns A promise that resolves to the result of the delete operation
|
|
60
57
|
*/
|
|
@@ -63,7 +60,6 @@ export class MongoCollectionClass {
|
|
|
63
60
|
}
|
|
64
61
|
/**
|
|
65
62
|
* Deletes multiple documents matching the filter criteria.
|
|
66
|
-
*
|
|
67
63
|
* @param filter - The filter criteria to match documents to delete
|
|
68
64
|
* @returns A promise that resolves to the result of the delete operation
|
|
69
65
|
*/
|
|
@@ -72,7 +68,6 @@ export class MongoCollectionClass {
|
|
|
72
68
|
}
|
|
73
69
|
/**
|
|
74
70
|
* Deletes a single document matching the filter criteria.
|
|
75
|
-
*
|
|
76
71
|
* @param filter - The filter criteria to match the document to delete
|
|
77
72
|
* @returns A promise that resolves to the result of the delete operation
|
|
78
73
|
*/
|
|
@@ -87,16 +82,24 @@ export class MongoCollectionClass {
|
|
|
87
82
|
}
|
|
88
83
|
/**
|
|
89
84
|
* Finds all distinct values for a key in the collection.
|
|
90
|
-
*
|
|
91
85
|
* @param key - The key to find distinct values for
|
|
92
86
|
* @returns A promise that resolves to an array of distinct values for the given key
|
|
93
87
|
*/
|
|
94
88
|
async distinct(key) {
|
|
95
89
|
return this.mongoCollection.distinct(key);
|
|
96
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Checks if a document with the given ID exists in the collection.
|
|
93
|
+
* @param id The ID of the document to check for existence.
|
|
94
|
+
* @returns A promise that resolves to true if the document exists, false otherwise.
|
|
95
|
+
*/
|
|
96
|
+
async exists(key, value) {
|
|
97
|
+
const filter = { [key]: value };
|
|
98
|
+
const doc = await this.mongoCollection.findOne(filter, { projection: { [key]: 1 } });
|
|
99
|
+
return doc !== null;
|
|
100
|
+
}
|
|
97
101
|
/**
|
|
98
102
|
* Finds a document by its ID.
|
|
99
|
-
*
|
|
100
103
|
* @param id - The ID of the document to find
|
|
101
104
|
* @returns A promise that resolves to the matching document or null if not found
|
|
102
105
|
*/
|
|
@@ -105,7 +108,6 @@ export class MongoCollectionClass {
|
|
|
105
108
|
}
|
|
106
109
|
/**
|
|
107
110
|
* Finds multiple documents matching the filter criteria with optional pagination and sorting.
|
|
108
|
-
*
|
|
109
111
|
* @param filter - (Optional) filter criteria to match documents
|
|
110
112
|
* @param perPage - (Optional) number of documents per page for pagination
|
|
111
113
|
* @param page - (Optional) page number for pagination
|
|
@@ -124,7 +126,6 @@ export class MongoCollectionClass {
|
|
|
124
126
|
}
|
|
125
127
|
/**
|
|
126
128
|
* Finds a single document matching the filter criteria.
|
|
127
|
-
*
|
|
128
129
|
* @param filter - The filter criteria to match the document
|
|
129
130
|
* @returns A promise that resolves to the matching document or null if not found
|
|
130
131
|
*/
|
|
@@ -133,18 +134,20 @@ export class MongoCollectionClass {
|
|
|
133
134
|
}
|
|
134
135
|
/**
|
|
135
136
|
* Gets the MongoDB collection instance.
|
|
136
|
-
*
|
|
137
137
|
* @returns The MongoDB collection instance
|
|
138
138
|
*/
|
|
139
139
|
async getCollection() {
|
|
140
140
|
return this.mongoCollection;
|
|
141
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Gets the MongoDB connector instance.
|
|
144
|
+
* @returns The MongoDB connector instance
|
|
145
|
+
*/
|
|
142
146
|
getMongoConnector() {
|
|
143
147
|
return this.mongoConnector;
|
|
144
148
|
}
|
|
145
149
|
/**
|
|
146
150
|
* Inserts a single document into the collection.
|
|
147
|
-
*
|
|
148
151
|
* @param doc - The document to insert
|
|
149
152
|
* @param options - The options for the insert operation
|
|
150
153
|
* @returns A promise that resolves to the result of the insert operation
|
|
@@ -177,7 +180,6 @@ export class MongoCollectionClass {
|
|
|
177
180
|
}
|
|
178
181
|
/**
|
|
179
182
|
* Updates a single document matching the filter criteria.
|
|
180
|
-
*
|
|
181
183
|
* @param filter - The filter criteria to match the document to update
|
|
182
184
|
* @param updateFields - The fields to update in the document
|
|
183
185
|
* @param options - The options for the update operation
|
|
@@ -207,7 +209,6 @@ export class MongoCollectionClass {
|
|
|
207
209
|
// }
|
|
208
210
|
/**
|
|
209
211
|
* Updates multiple documents matching the filter criteria.
|
|
210
|
-
*
|
|
211
212
|
* @param filter - The filter criteria to match documents to update
|
|
212
213
|
* @param updateFields - The fields to update in the documents
|
|
213
214
|
* @param options - The options for the update operation
|
|
@@ -227,7 +228,6 @@ export class MongoCollectionClass {
|
|
|
227
228
|
}
|
|
228
229
|
/**
|
|
229
230
|
* Updates a single document matching the filter criteria.
|
|
230
|
-
*
|
|
231
231
|
* @param filter - The filter criteria to match the document to update
|
|
232
232
|
* @param updateFields - The fields to update in the document
|
|
233
233
|
* @param options - The options for the update operation
|
package/package.json
CHANGED