Skip to content

Commit 429f608

Browse files
Update document.d.ts
/** * Alias for `set()`, used internally to avoid conflicts * * @param {String|Object} path path or object of key/vals to set * @param {Any} val the value to set * @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for "on-the-fly" attributes * @param {Object} [options] optionally specify options that modify the behavior of the set * @param {Boolean} [options.merge=false] if true, setting a [nested path](/docs/subdocs.html#subdocuments-versus-nested-paths) will merge existing values rather than overwrite the whole object. So `doc.set('nested', { a: 1, b: 2 })` becomes `doc.set('nested.a', 1); doc.set('nested.b', 2);` * @return {Document} this * @method $set * @memberof Document * @instance * @api public */
1 parent dee524b commit 429f608

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

types/document.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ declare module 'mongoose' {
9090
$session(session?: ClientSession | null): ClientSession | null;
9191

9292
/** Alias for `set()`, used internally to avoid conflicts */
93-
$set(path: string, val: any, type: any, options?: DocumentSetOptions): this;
94-
$set(path: string, val: any, options?: DocumentSetOptions): this;
95-
$set(value: any): this;
93+
$set(path: string | Record<string, any>, val: any, type: any, options?: DocumentSetOptions): this;
94+
$set(path: string | Record<string, any>, val: any, options?: DocumentSetOptions): this;
95+
$set(value: string | Record<string, any>): this;
9696

9797
/** Set this property to add additional query filters when Mongoose saves this document and `isNew` is false. */
9898
$where: Record<string, unknown>;
@@ -216,9 +216,9 @@ declare module 'mongoose' {
216216
schema: Schema;
217217

218218
/** Sets the value of a path, or many paths. */
219-
set(path: string, val: any, type: any, options?: any): this;
220-
set(path: string, val: any, options?: any): this;
221-
set(value: any): this;
219+
set(path: string | Record<string, any>, val: any, type: any, options?: DocumentSetOptions): this;
220+
set(path: string | Record<string, any>, val: any, options?: DocumentSetOptions): this;
221+
set(value: string | Record<string, any>): this;
222222

223223
/** The return value of this method is used in calls to JSON.stringify(doc). */
224224
toJSON<T = Require_id<DocType>>(options?: ToObjectOptions & { flattenMaps?: true }): FlattenMaps<T>;

0 commit comments

Comments
 (0)