This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mongoose): Add SchemaTypeOpts as options parameter to Model deco…
- Loading branch information
Showing
5 changed files
with
20 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { getMongooseMeta } from '../meta'; | ||
|
||
import { SchemaTypeOpts } from 'mongoose'; | ||
/** | ||
* Defines model class | ||
* @param {String} name Model name | ||
* @param {SchemaTypeOpts} options | ||
*/ | ||
export let Model = (name: string) => { | ||
export let Model = (name: string, options?: SchemaTypeOpts<any>) => { | ||
return (target: Function) => { | ||
getMongooseMeta(target.prototype).name = name; | ||
const mongooseMeta = getMongooseMeta(target.prototype); | ||
mongooseMeta.name = name; | ||
if (options) { | ||
Object.keys(options) | ||
.forEach((key) => { | ||
mongooseMeta.options.push(key, options[key]); | ||
}); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters