@tmlmobilidade/interfaces 20250911.1425.9 → 20250911.1527.52
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.
|
@@ -112,7 +112,9 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
112
112
|
insertOne<TReturnDocument extends boolean = true>(doc: TCreate & {
|
|
113
113
|
_id?: string;
|
|
114
114
|
created_at?: UnixTimestamp;
|
|
115
|
+
created_by?: string;
|
|
115
116
|
updated_at?: UnixTimestamp;
|
|
117
|
+
updated_by?: string;
|
|
116
118
|
}, { options, unsafe }?: {
|
|
117
119
|
options?: InsertOneOptions & {
|
|
118
120
|
returnResult?: TReturnDocument;
|
|
@@ -136,7 +138,10 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
136
138
|
* @param options - The options for the update operation
|
|
137
139
|
* @returns A promise that resolves to the result of the update operation
|
|
138
140
|
*/
|
|
139
|
-
updateMany<TReturnDocument extends boolean = true>(filter: Filter<T>, updateFields: TUpdate
|
|
141
|
+
updateMany<TReturnDocument extends boolean = true>(filter: Filter<T>, updateFields: TUpdate & {
|
|
142
|
+
updated_at?: UnixTimestamp;
|
|
143
|
+
updated_by?: string;
|
|
144
|
+
}, options?: UpdateOptions & {
|
|
140
145
|
returnResults?: TReturnDocument;
|
|
141
146
|
}): Promise<TReturnDocument extends true ? WithId<T>[] : UpdateResult<T>>;
|
|
142
147
|
/**
|
|
@@ -181,7 +181,9 @@ export class MongoCollectionClass {
|
|
|
181
181
|
...doc,
|
|
182
182
|
_id: doc._id || generateRandomString({ length: 5 }),
|
|
183
183
|
created_at: doc.created_at || Dates.now('utc').unix_timestamp,
|
|
184
|
+
created_by: doc.created_by || 'system',
|
|
184
185
|
updated_at: doc.updated_at || Dates.now('utc').unix_timestamp,
|
|
186
|
+
updated_by: doc.updated_by || 'system',
|
|
185
187
|
};
|
|
186
188
|
if (!doc._id) {
|
|
187
189
|
while (await this.findById(newDocument._id)) {
|
|
@@ -231,7 +233,11 @@ export class MongoCollectionClass {
|
|
|
231
233
|
* @returns A promise that resolves to the result of the update operation
|
|
232
234
|
*/
|
|
233
235
|
async updateMany(filter, updateFields, options) {
|
|
234
|
-
let parsedUpdateFields =
|
|
236
|
+
let parsedUpdateFields = {
|
|
237
|
+
...updateFields,
|
|
238
|
+
updated_at: updateFields.updated_at || Dates.now('utc').unix_timestamp,
|
|
239
|
+
updated_by: updateFields.updated_by || 'system',
|
|
240
|
+
};
|
|
235
241
|
if (this.updateSchema) {
|
|
236
242
|
try {
|
|
237
243
|
parsedUpdateFields = this.updateSchema.parse(updateFields);
|
package/package.json
CHANGED