style: fix some typos (#754)

Co-authored-by: hasezoey <hasezoey@gmail.com>
pull/763/head
Lioness100 9 months ago committed by GitHub
parent c2e899933e
commit 12b7007b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .eslintignore
  2. 2
      .eslintrc.js
  3. 2
      .github/CONTRIBUTING.md
  4. 4
      .github/ISSUE_TEMPLATE/bug.md
  5. 2
      .github/ISSUE_TEMPLATE/question.md
  6. 4
      .releaserc.js
  7. 56
      CHANGELOG.md
  8. 2
      docs/api/decorators/indexes.md
  9. 2
      docs/api/decorators/modelOptions.md
  10. 12
      docs/api/decorators/prop.md
  11. 2
      docs/guides/advanced/models-with-same-name.md
  12. 6
      docs/guides/advanced/name-generation.md
  13. 2
      docs/guides/advanced/nested-discriminators.mdx
  14. 4
      docs/guides/advanced/non-nested-discriminators.mdx
  15. 24
      docs/guides/error-warning-details.md
  16. 4
      docs/guides/faq.md
  17. 4
      docs/guides/integration-examples/common-plugins.mdx
  18. 6
      docs/guides/integration-examples/deepkit-type.md
  19. 2
      docs/guides/known-issues.md
  20. 2
      docs/guides/migration/migrate-6.md
  21. 2
      docs/guides/migration/migrate-7.md
  22. 4
      docs/guides/use-without-emitDecoratorMetadata.md
  23. 2
      src/defaultClasses.ts
  24. 4
      src/hooks.ts
  25. 2
      src/internal/constants.ts
  26. 4
      src/internal/errors.ts
  27. 2
      src/internal/processProp.ts
  28. 4
      src/internal/utils.ts
  29. 6
      src/typegoose.ts
  30. 4
      src/typeguards.ts
  31. 10
      src/types.ts
  32. 12
      test/models/discriminatorsWithGenerics.ts
  33. 2
      test/models/hook1.ts
  34. 0
      test/models/indexweights.ts
  35. 2
      test/models/job.ts
  36. 2
      test/tests/__snapshots__/biguser.test.ts.snap
  37. 2
      test/tests/__snapshots__/errors.test.ts.snap
  38. 2
      test/tests/biguser.test.ts
  39. 2
      test/tests/dbIndex.test.ts
  40. 4
      test/tests/deepkitType.test.ts
  41. 6
      test/tests/discriminators.test.ts
  42. 2
      test/tests/getClassForDocument.test.ts
  43. 2
      test/tests/hooks.test.ts
  44. 4
      test/tests/inheritance.test.ts
  45. 2
      test/tests/modelOptions.test.ts
  46. 4
      test/tests/nestedDiscriminators.test.ts
  47. 2
      test/tests/overwrittenModel.test.ts
  48. 2
      test/tests/ref.test.ts
  49. 2
      test/tests/shouldAdd.test.ts
  50. 16
      test/tests/shouldRun.test.ts
  51. 6
      test/tests/types/basicTypegoose.test-d.ts
  52. 2
      website/README.md
  53. 2
      website/src/pages/index.js

@ -1,7 +1,7 @@
flow-typed/*
lib/*
build/*
#website/* #dont ignore website (like sidebars.js)
#website/* #don't ignore website (like sidebars.js)
website/build/*
coverage/*
#*.js # dont ignore top-level js files
#*.js # don't ignore top-level js files

@ -85,7 +85,7 @@ module.exports = {
{
blankLine: 'never',
prev: 'import',
next: 'import', // dont allow blank line between imports
next: 'import', // don't allow blank line between imports
},
],
'eol-last': 'warn',

@ -106,4 +106,4 @@ When doing code examples in the documentation:
When generally writing (outside of code examples):
- use inline-code-blocks for versions, code, variable names, etc (like: `this is an inline-code-block`)
- use double-quotes for things that dont need inline-code-blocks
- use double-quotes for things that don't need inline-code-blocks

@ -11,7 +11,7 @@ assignees: ''
<!--
- Only include the verions & packages that were used in the environment where typegoose ran
- in "Code Example" add as many code blocks as needed, but when possible try to use an repo / gist
- in "Do you know *why* it happenes replace the "*no*" if you know why
- in "Do you know *why* it happens replace the "*no*" if you know why
- Make sure you read [Mastering-Markdown](https://guides.github.com/features/mastering-markdown/)
-->
@ -53,4 +53,4 @@ code here
---
<!--Write extra below here that dosnt fit in any header-->
<!--Write extra below here that doesn't fit in any header-->

@ -36,4 +36,4 @@ assignees: ''
---
<!--Write extra below here that dosnt fit in any header-->
<!--Write extra below here that doesn't fit in any header-->

@ -16,7 +16,7 @@ module.exports = {
{type: 'chore', release: false},
{type: 'dependencies', release: 'minor'},
{type: 'revert', release: 'patch'},
// dont trigger another release on release commit
// don't trigger another release on release commit
{type: 'release', release: false}
],
parserOpts: {
@ -62,7 +62,7 @@ module.exports = {
'@semantic-release/github'
],
branches: [
// from what i read in the semantic-release configuration and in some issues, the order has to be like this:
// from what I read in the semantic-release configuration and in some issues, the order has to be like this:
// other branches
// main / upstream branch
// prerelease branches

@ -348,7 +348,7 @@
### [9.8.1](https://github.com/typegoose/typegoose/compare/v9.8.0...v9.8.1) (2022-04-21)
The Type change in this release may break some array post hooks and need to be seperated
The Type change in this release may break some array post hooks and need to be separated
### Fixes
@ -497,7 +497,7 @@ The Type change in this release may break some array post hooks and need to be s
### Dependencies
* **@types/lodsash:** upgrade to 4.14.178 ([ea8ff31](https://github.com/typegoose/typegoose/commit/ea8ff310469e90140349466f36751ae405b8adc4))
* **@types/lodash:** upgrade to 4.14.178 ([ea8ff31](https://github.com/typegoose/typegoose/commit/ea8ff310469e90140349466f36751ae405b8adc4))
* **@types/node:** upgrade to 12.20.38 ([35d9822](https://github.com/typegoose/typegoose/commit/35d9822a6eb8de897c3fa73dbbb1b7f84bbb3192))
* **@typescript-eslint/*:** upgrade to 5.7.0 ([0197ffe](https://github.com/typegoose/typegoose/commit/0197ffe86dd252ae568c8721c9b6dc613ceb0059))
* **@typescript-eslint/*:** upgrade to 5.8.0 ([d7fcad1](https://github.com/typegoose/typegoose/commit/d7fcad1040de81caf535492982f10aa2e0bd0485))
@ -558,7 +558,7 @@ The Type change in this release may break some array post hooks and need to be s
### Dependencies
* **@types/lodsash:** upgrade to 4.14.178 ([ea8ff31](https://github.com/typegoose/typegoose/commit/ea8ff310469e90140349466f36751ae405b8adc4))
* **@types/lodash:** upgrade to 4.14.178 ([ea8ff31](https://github.com/typegoose/typegoose/commit/ea8ff310469e90140349466f36751ae405b8adc4))
* **@typescript-eslint/*:** upgrade to 5.7.0 ([0197ffe](https://github.com/typegoose/typegoose/commit/0197ffe86dd252ae568c8721c9b6dc613ceb0059))
* **eslint:** upgrade to 8.4.1 ([aff4c54](https://github.com/typegoose/typegoose/commit/aff4c546c01098e47d8f599bcd3d6cc911bf19f9))
* **jest:** upgrade to 27.4.5 ([980f89c](https://github.com/typegoose/typegoose/commit/980f89c4b3356691ab9a6e3c0445a6fd5eb41e6d))
@ -685,7 +685,7 @@ Co-authored-by: hasezoey <hasezoey@gmail.com>
* **errors:** rename "CannotBeSymbol" to "CannotBeSymbolError" to match style ([454c23b](https://github.com/typegoose/typegoose/commit/454c23b0d4de4dc95dea48316339c33697ca0c5b))
* **processProp:** merge Error "E008" into "E026" ([3469a22](https://github.com/typegoose/typegoose/commit/3469a22e847d1ad4833b8bf263c759018e9a1224))
* **processProp:** remove Error E007 ([928f51d](https://github.com/typegoose/typegoose/commit/928f51df82d8ccc845ecb5bf0c67c66fa61347e7)), closes [typegoose/typegoose#599](https://github.com/typegoose/typegoose/issues/599)
* **typegoose:** add option to use "Passthrough" directly (no "type" property inbetween) ([7379810](https://github.com/typegoose/typegoose/commit/73798104c8865e80ababba1663946fda6fefdb11))
* **typegoose:** add option to use "Passthrough" directly (no "type" property in between) ([7379810](https://github.com/typegoose/typegoose/commit/73798104c8865e80ababba1663946fda6fefdb11))
* **utils::mergeMetadata:** change custom error to use "StringLengthExpectedError" ([9ad3013](https://github.com/typegoose/typegoose/commit/9ad30133a5967fe2b889c00ad1e97314a03f6401))
* change build order to bottom-up (when extending classes) ([#243](https://github.com/typegoose/typegoose/issues/243)) ([79977ee](https://github.com/typegoose/typegoose/commit/79977ee675a48fda280be5a10bc9b962721cd5dc))
* merge errors "E023" into "E013" ([c8ce9b8](https://github.com/typegoose/typegoose/commit/c8ce9b8c36d82f9d23e66d4cdda86cb86567b4fa))
@ -781,7 +781,7 @@ Co-authored-by: hasezoey <hasezoey@gmail.com>
### Features
* **typegoose:** add option to use "Passthrough" directly (no "type" property inbetween) ([7379810](https://github.com/typegoose/typegoose/commit/73798104c8865e80ababba1663946fda6fefdb11))
* **typegoose:** add option to use "Passthrough" directly (no "type" property in between) ([7379810](https://github.com/typegoose/typegoose/commit/73798104c8865e80ababba1663946fda6fefdb11))
### Dependencies
@ -1052,8 +1052,8 @@ Co-authored-by: hasezoey <hasezoey@gmail.com>
* **processProp:** "ref" and "refPath" now use "mapArrayOptions" that means that some options might be mapped differently
* Changing types from unofficial to official is an breaking change
* **prop:** Removing deprecated options "items", "of", "refType"
* **prop:** Removeing deprecated function "mapProp"
* **prop:** Removeing deprecated function "arrayProp"
* **prop:** Removing deprecated function "mapProp"
* **prop:** Removing deprecated function "arrayProp"
### Features
@ -1140,7 +1140,7 @@ Co-authored-by: hasezoey <hasezoey@gmail.com>
* **semantic-release:** upgrade to version "17.4.2" ([283afb1](https://github.com/typegoose/typegoose/commit/283afb15427650941236dce9583b4315152a6e36))
* **semantic-release:** upgrade to version "17.4.3" ([ed4cbfc](https://github.com/typegoose/typegoose/commit/ed4cbfce8a67e18692d2de1436ecaac72bbae773))
* **semantic-release:** upgrade to version "17.4.4" ([090d05f](https://github.com/typegoose/typegoose/commit/090d05f964f680767fc8321a1525e6fdf2a60078))
* **ts-jest:** upgrad eto version 27.0.4 ([e20fd0c](https://github.com/typegoose/typegoose/commit/e20fd0c7f0f01442591b8f604c8fab5a8be7fc43))
* **ts-jest:** upgrade eto version 27.0.4 ([e20fd0c](https://github.com/typegoose/typegoose/commit/e20fd0c7f0f01442591b8f604c8fab5a8be7fc43))
* **ts-jest:** upgrade to version "26.5.4" ([047051b](https://github.com/typegoose/typegoose/commit/047051bc0bb6c280c82914ae4a13e7e733faa02d))
* **ts-jest:** upgrade to version "27.0.3" ([dc0452f](https://github.com/typegoose/typegoose/commit/dc0452ffa5f5a58de24e4bd154119571d9d7fb96))
* **tslib:** upgrade to version "2.2.0" ([edd2581](https://github.com/typegoose/typegoose/commit/edd2581db6e572bbd7286a307ed3fcf7761ca140))
@ -1197,7 +1197,7 @@ Co-authored-by: hasezoey <hasezoey@gmail.com>
* **lint-staged:** upgrade to version 11.1.1 ([5f370ad](https://github.com/typegoose/typegoose/commit/5f370ad81faff038c1dad5997d018def79fc880c))
* **mongodb-memory-server:** upgrade to version 7.3.4 ([460bdcb](https://github.com/typegoose/typegoose/commit/460bdcbc0a050c678c5eac42d8333558d07c72f5))
* **mongoose:** upgrade to version 5.13.3 ([c7414e6](https://github.com/typegoose/typegoose/commit/c7414e649369c0198b80fffc5004d6c014600cde))
* **ts-jest:** upgrad eto version 27.0.4 ([e20fd0c](https://github.com/typegoose/typegoose/commit/e20fd0c7f0f01442591b8f604c8fab5a8be7fc43))
* **ts-jest:** upgrade eto version 27.0.4 ([e20fd0c](https://github.com/typegoose/typegoose/commit/e20fd0c7f0f01442591b8f604c8fab5a8be7fc43))
### Style
@ -1645,7 +1645,7 @@ Everything Below here is manually made:
- Add Error Codes [Errors & Warnings Details](guides/error-warnings-details.md)
- Remove never triggered Error `InvalidPropError`
- Change "Options-not-for-current-type" Errors into warnings (with actual information on what options are included) [[typegoose#363](https://github.com/typegoose/typegoose/issues/363)]
- [IC] Assing `schemaOptions` in `src/internal/schema.ts` to an black object [[typegoose#357](https://github.com/typegoose/typegoose/issues/357)]
- [IC] Assigning `schemaOptions` in `src/internal/schema.ts` to an black object [[typegoose#357](https://github.com/typegoose/typegoose/issues/357)]
## 7.3.4
@ -1653,7 +1653,7 @@ Everything Below here is manually made:
## 7.3.3
- Dont assume that the plugin function has an name [[typegoose#353](https://github.com/typegoose/typegoose/issues/353)]
- Don't assume that the plugin function has an name [[typegoose#353](https://github.com/typegoose/typegoose/issues/353)]
- Only check mongoose & nodejs version if `process` is defined
- [IC] replace all `util.format` with template strings [[typegoose#348](https://github.com/typegoose/typegoose/issues/348)]
- [IC] add wrapper & polyfill for `util.deprecate`[[typegoose#344](https://github.com/typegoose/typegoose/issues/344)]
@ -1684,12 +1684,12 @@ Everything Below here is manually made:
- Add option `discriminators` for embedded Discriminators [[typegoose#248](https://github.com/typegoose/typegoose/issues/248)]
- Set correct Decorator Return type (`ClassDecorator` & `PropertyDecorator`)
- Change warning message for `warnMixed`
- If an SchemaType dosnt extend `SchemaTypeOptions`, the options are now defaulted to the outer-layer
- If an SchemaType doesn't extend `SchemaTypeOptions`, the options are now defaulted to the outer-layer
- `innerOptions` and `outerOptions` can now be used for Maps too
- Custom Validators now support `message` being an function
- Automatically convert `mongoose.Types.Buffer` to `mongoose.Schema.Types.Buffer`
- Fix Types when extending default class `Base` with other than `ObjectId` [[typegoose#316](https://github.com/typegoose/typegoose/issues/316)]
- [IC] `mapOptions` now always errors if the given type dosnt extend `mongoose.SchemaTypeOptions`
- [IC] `mapOptions` now always errors if the given type doesn't extend `mongoose.SchemaTypeOptions`
- [IC] Moved function `_buildPropMetadata` to its own file (`processProp`) and renamed it to `processProp` [[typegoose#286](https://github.com/typegoose/typegoose/issues/286)]
- [IC] Moved pre-processing in function `prop` into `processProp` [[typegoose#286](https://github.com/typegoose/typegoose/issues/286)]
- [IC] Removed error `NoMetadataError`
@ -1716,9 +1716,9 @@ Everything Below here is manually made:
## 7.1.2
- `@prop` options types now work again
- `BasePropOptions.type` is now `unkown` instead of `any`
- `BasePropOptions.type` is now `unknown` instead of `any`
- All aliases of `BasePropOptions.type` now inherit the types from there
- Fix bug where autopopulate (or any other plugin) wouldnt pick up on virtuals [[typegoose#274](https://github.com/typegoose/typegoose/issues/274)]
- Fix bug where autopopulate (or any other plugin) wouldn't pick up on virtuals [[typegoose#274](https://github.com/typegoose/typegoose/issues/274)]
- [IC] `refType` is now moved to `prop`
## 7.1.1
@ -1759,7 +1759,7 @@ Everything Below here is manually made:
- The functions `addModelToTypegoose`, `getModelForClass`, `getDiscriminatorModelForClass` now have an new optional generic `QueryHelpers`
- The Type `ReturnModelType` now has the `T` generic removed (it was unnecessary)
- The Type `ReturnModelType` now has an second optional generic `QueryHelpers`
- Fix bug where `ref: Class` didnt execute `getName` when Virtual-Populate was used
- Fix bug where `ref: Class` didn't execute `getName` when Virtual-Populate was used
- Allow use of `@prop` for arrays & maps (In preparation for 8.0), it is now auto-detected based on `design:type`
- The Decorator `@plugin` now automatically infers the options if the plugin & function have typings and use options
- [IC] add some tslint rules & apply them
@ -1774,7 +1774,7 @@ Everything Below here is manually made:
- `@types/mongoose` to 5.7.12
- Minimal NodeJS version is now 10.15
- Minimal Typescript version is now 3.8.3
- Typegoose class got completly removed
- Typegoose class got completely removed
- All Deprecated `arrayProp` options got remove
- `itemsRef` replaced with plain `ref`
- `itemsRefPath` replaced with plain `refPath`
@ -1782,7 +1782,7 @@ Everything Below here is manually made:
- All enums got moved from `src/types` to `src/internal/constants`
- All things from `src/types` now get exported as `type`
- All Errors now get exported as `errors`
- All non-essentail types get exported as `types`
- All non-essential types get exported as `types`
- `utils`'s `getName` function now gets exported
- Add PropOption `addNullToEnum`
- Remove Deprecated value `overwrite` for `VirtualOptions`
@ -1790,7 +1790,7 @@ Everything Below here is manually made:
- Add class decorator `queryMethod`
- [IC] rename file `optionsProp` to `modelOptions`
- [IC] Replace mocha & chai with jest
- [IC] Completly remove `TG_USE_NEW_ENUM` from documentation & code
- [IC] Completely remove `TG_USE_NEW_ENUM` from documentation & code
- [IC] Replace almost all if-throw with the internal `assertion` function
- [IC] Move VirtualPopulate cache to Reflection
- [IC] Move Plugins cache to Reflection
@ -1817,7 +1817,7 @@ Everything Below here is manually made:
- `semver` to 7.1.3
- `loglevel` to 1.6.7
- `tslib` to 1.11.0
- Completly remove `__uniqueID`, because it was not used internally anymore
- Completely remove `__uniqueID`, because it was not used internally anymore
## 6.3.2
@ -1835,7 +1835,7 @@ Everything Below here is manually made:
- `semver` to 7.1.2
- Add `@types/mongoose` to `peerDependencies`
- Add generic type to `@plugin` to set the type for the options
- Use a modified `Ref`-Type to automatically get the type (if the Ref'd type has `string` as `_id`, it automaticly sets the `RefType` to `string`)
- Use a modified `Ref`-Type to automatically get the type (if the Ref'd type has `string` as `_id`, it automatically sets the `RefType` to `string`)
## 6.2.2
@ -1854,7 +1854,7 @@ This Update may break some code (mongoose upgrade, inline `_id` change, `enum` c
- Upgrade @types/mongoose from 5.5.30 to 5.5.35
- [IC] Upgrade Typescript from 3.7.2 to 3.7.4
- [IC] Upgrade NYC from 14.1.1 to 15.0.0
- The option `useNewEnum` (and `TG_USE_NEW_ENUM`) got removed, because it would interfer with the number-enums
- The option `useNewEnum` (and `TG_USE_NEW_ENUM`) got removed, because it would interfere with the number-enums
- Added the ability to use number-enums on number-type props
- Changed behaviour of string-enums to only work on string-type props
- Fix `PropOptions` type for `autopopulate`
@ -1894,7 +1894,7 @@ This Update may break some code (mongoose upgrade, inline `_id` change, `enum` c
## 6.1.3
- fix bug when "buildSchema" didnt get called when overwriting the type in `@prop`
- fix bug when "buildSchema" didn't get called when overwriting the type in `@prop`
- [IC] add tests for Generic Discriminators
## 6.1.2
@ -1912,7 +1912,7 @@ This Update may break some code (mongoose upgrade, inline `_id` change, `enum` c
- Update Dependencies
- Upgrade mongoose from 5.7.1 to 5.7.7
- [IC] Upgrade Typescript from 3.6.x to 3.7.2
- Completly remove `@staticMethod` & `@instanceMethod`, because they were completly obsolete
- Completely remove `@staticMethod` & `@instanceMethod`, because they were completely obsolete
- README now has no documentation anymore
- `@prop({ validate })` now accepts `{ validator, message }` as an array
- Add function `deleteModel` & `deleteModelWithClass`
@ -1942,12 +1942,12 @@ This Update may break some code (mongoose upgrade, inline `_id` change, `enum` c
- [IC] Refactor how "isPrimitive" works, some types like `Buffer` & `Decimal` now work
- [IC] Added more debug logs to `prop.ts`
- [IC] Move Decorator Cache to the class itself
- [IC] "baseProp" now uses one single arguments, whith all the options
- [IC] "baseProp" now uses one single arguments, with all the options
- [IC] "createUniqueID" now returns a boolean instead of the "initname"
## 6.0.4
This Release didnt change anything on the code, it was mostly tests & github-page
This Release didn't change anything on the code, it was mostly tests & github-page
- Update Dependencies
- Upgrade mongoose from 5.7.1 to 5.7.4
- Added soft warning when using "ref" in an "arrayProp"
@ -2006,7 +2006,7 @@ This Release didnt change anything on the code, it was mostly tests & github-pag
- adding Types to Ref (to allow not just ObjectID) [[szokodiakos#369](https://github.com/szokodiakos/typegoose/issues/369)]
- szokodiakos#54 seems to work now in 6.0.0 (added test in 6.0.0-21)
- because of the changes in 6.0.0 #235 got fixed
- Adding "InvalidTypeError" for the case that "undefined" or "null" is used as a type (or something other happenes)
- Adding "InvalidTypeError" for the case that "undefined" or "null" is used as a type (or something other happens)
- Change Error text of "InvalidPropError"
- adding some "soft-errors" and traces with "loglevel"
- exposing settings for "loglevel"
@ -2046,7 +2046,7 @@ This Release did not change anything in the code, it is just there to update the
- This should not be a breaking release
- Hooks now support Regular Expression for names, like mongoose
- Tests are splitted into their own files
- Tests are split into their own files
- Fixing `itemsRefPath` & adding tests
- `itemsRef` now supports to be used with a string as model
- `@prop({ alias })` is now supported

@ -21,7 +21,7 @@ function index<T extends BeAnObject = BeAnObject>(fields: mongoose.IndexDefiniti
`@index` is used to set indices on the schema, this decorator acts like `schema.index()`.
:::note
For [Full-Text Search](https://docs.mongodb.com/manual/tutorial/control-results-of-text-search/) option `weights` all fields (from `fields`) have to also be defined in `weigths`.
For [Full-Text Search](https://docs.mongodb.com/manual/tutorial/control-results-of-text-search/) option `weights` all fields (from `fields`) have to also be defined in `weights`.
:::
## Example

@ -95,7 +95,7 @@ expect(model.modelName).to.be.equal('MultiModel_Something');
#### automaticName
`automaticName` can be used to automatically generate custom model names based on `{ schemaOptions: { collection } }` or `{ options: { customName } }`
-> `customName` will be prioritzed over `collection`
-> `customName` will be prioritized over `collection`
-> if `automaticName` is true, `customName` will be a *suffix* of the base class name
-> if `automaticName` is false, it will behave as if unset

@ -257,7 +257,7 @@ class Dummy {
Accepts Type: `boolean`
Set it to `false`, if you want to retrieve data without this property by default
-> [Read more in Mongoose's offical documentation](https://mongoosejs.com/docs/api.html#schematype_SchemaType-select)
-> [Read more in Mongoose's official documentation](https://mongoosejs.com/docs/api.html#schematype_SchemaType-select)
```ts
class Dummy {
@ -677,7 +677,7 @@ class Something {
}
```
This option `dim` can be ommitted, when used with the `() => [Type]` syntax (since `7.4.0`):
This option `dim` can be omitted, when used with the `() => [Type]` syntax (since `7.4.0`):
```ts
class ArrayInType {
@ -757,7 +757,7 @@ class LowerCased {
Accepts Type: `boolean`
Set this to `true`, if the value should always be transformed to be UPPERCASE. <!--please dont change this to lowercase-->
Set this to `true`, if the value should always be transformed to be UPPERCASE. <!--please don't change this to lowercase-->
Example:
@ -891,14 +891,14 @@ Set the field to look at in the local document and be compared with the field se
Accepts Type: `boolean`
Conflicts with: [`count`](#count)
Set wheter the query should only return one document instead of a array of documents.
Set whether the query should only return one document instead of a array of documents.
### count
Accepts Type: `boolean`
Conflicts with: [`justOne`](#justone)
Set wheter the query should return a count of found documents instead of the documents themself.
Set whether the query should return a count of found documents instead of the documents themself.
### options {#virtual-populate-options-option}
@ -952,7 +952,7 @@ Also see the [FAQ `Do all Classes get compiled to their own "mongoose.Schema"?`]
It should be noted that using this method no typegoose transformations or warnings will be applied to what is inside `Passthrough.raw` (like `type: () => Class` will not be translated, it will stay as-is).
:::
There is also a option to set the `Passthrough` class to `direct` mode (with the second parameter), this will mean that absolutlely no typegoose process is applied (everything has to be done manually), see [Passthrough-Class#Direct](#passthrough-direct).
There is also a option to set the `Passthrough` class to `direct` mode (with the second parameter), this will mean that absolutely no typegoose process is applied (everything has to be done manually), see [Passthrough-Class#Direct](#passthrough-direct).
Example for `PropType.NONE`:

@ -6,7 +6,7 @@ title: 'Models with same name'
This Guide shows all the possibilities for a model to use different names.
:::note
If Classes with the same name are wanted, these methods need to be used so that Typegooes can differentiate between them
If Classes with the same name are wanted, these methods need to be used so that Typegoose can differentiate between them
:::
:::info

@ -61,14 +61,14 @@ When using the option [`customName`](../../api/decorators/modelOptions.md#custom
Example:
```ts
// Example having "customName" staticly set
// Example having "customName" statically set
@modelOptions({ options: { customName: "Hello" } })
class SomeClassWithCustomName {
@prop()
public someProp: string;
}
// The resulting name will be the staticly defined "customName"
// The resulting name will be the statically defined "customName"
assertion(getName(SomeClassWithCustomName) === 'Hello');
// Example having "customName" be a function
@ -94,7 +94,7 @@ When using option [`automaticName`](../../api/decorators/modelOptions.md#automat
Example:
```ts
// Example having "customName" staticly set and having "automaticName"
// Example having "customName" statically set and having "automaticName"
@modelOptions({ options: { customName: "Hello", automaticName: true } })
class SomeClassWithCustomNameAndAutomaticName {
@prop()

@ -12,7 +12,7 @@ import TabItem from '@theme/TabItem';
## Use-Case
If you dont know an use case for this, consider the following:
If you don't know an use case for this, consider the following:
A Veterinarian that wants to store medication information about the current patients in their care, how would it be done in mongoose / typegoose?
:::note

@ -12,7 +12,7 @@ import TabItem from '@theme/TabItem';
## Use-Case
If you dont know an use case for this, consider the following:
If you don't know an use case for this, consider the following:
A Veterinarian that wants to store information about the current patients in their care, how would it be done in mongoose / typegoose?
## First thought
@ -371,7 +371,7 @@ class Animal {
@prop({ required: true, unique: true })
public patientNumber!: number;
// options "enum" & "default" can also be specified, but dont have much effect
// options "enum" & "default" can also be specified, but don't have much effect
// the property set in "discriminatorKey" does not actually need to be defined, but its for types like usage in an typeguard
@prop({ required: true })
public customKey!: string; // its recommended to only use "string" or "number"

@ -25,7 +25,7 @@ Error: `You are using a NodeJS Version below 12.22.0, Please Upgrade! [E002]`
Error Class: `Error`
Details:
Typegoose requires at least NodeJS Version 12.22, because NodeJS 12 is the lowest activly maintained version AND is the lowest that supports all functions needed by typegoose (without having to add polyfills)
Typegoose requires at least NodeJS Version 12.22, because NodeJS 12 is the lowest actively maintained version AND is the lowest that supports all functions needed by typegoose (without having to add polyfills)
### Function only supports to be called "${supported}" times [E003]
@ -41,7 +41,7 @@ Error Class: `FunctionCalledMoreThanSupportedError`
Details:
For example [`addModelToTypegoose`](../api/functions/addModelToTypegoose.md) only supports to be called once (1) with the same model name, [this problem has a specific Guide](./advanced/models-with-same-name.md).
### Self Containg Class [E004]
### Self Containing Class [E004]
Error:
@ -67,7 +67,7 @@ Either:
- The Option `ref` was defined with a function, but that function returned `undefined / null`
- The Option `ref` was defined with `undefined / null` (`{ ref: undefined }`) ([Can Be Solved with this guide](./advanced/reference-other-classes.md#common-problems))
Example of when this gets triggerd:
Example of when this gets triggered:
```ts
class ErrorClass {
@ -192,7 +192,7 @@ This may be thrown when using typescript option `transpileOnly` (see [Known Issu
This Error has a workaround, see [Use Without "emitDecoratorMetadata"](./use-without-emitDecoratorMetadata.md).
:::
<!--The Following "a" is a backwards-comaptability anchor-->
<!--The Following "a" is a backwards-compatability anchor-->
<a name="invalid-whatisit-used-e013"></a>
### Invalid PropType used [E013]
@ -209,14 +209,14 @@ The Value `${proptype}` is not supported in `${where}` or does not exist in the
Error:
```txt
Input was not a string AND didnt have a .typegooseName function AND didnt have a .typegooseName string [E014]
Input was not a string AND didn't have a .typegooseName function AND didn't have a .typegooseName string [E014]
Value: "${toStringNoFail(input)}"
```
Error Class: `ResolveTypegooseNameError`
Details:
The Provided Input `input` was not a string and didnt have a `.typegooseName` function / string to be searched by.
The Provided Input `input` was not a string and didn't have a `.typegooseName` function / string to be searched by.
### customName must be string and at least one character [E015]
@ -233,7 +233,7 @@ Error Class: [`TypeError`](https://github.com/typegoose/typegoose/blob/8fad2ac21
Details:
The `customName` option must be a String AND at least *one* character long
### Type dosnt have "OptionsConstructor" [E016]
### Type doesn't have "OptionsConstructor" [E016]
Error:
@ -247,9 +247,9 @@ Error Class: `InvalidOptionsConstructor`
Details:
The Type provided `type` does not have a `OptionsConstructor` property, this property is required to map options correctly.
Typegoose uses the property [`OptionsConstructor`](https://github.com/Automattic/mongoose/tree/master/lib/options) on types (like `mongoose.Schema.Types.ObjectId.OptionsConstructor`) to correctly map the options (from `@prop(options)`) to the appropiate place.
Typegoose uses the property [`OptionsConstructor`](https://github.com/Automattic/mongoose/tree/master/lib/options) on types (like `mongoose.Schema.Types.ObjectId.OptionsConstructor`) to correctly map the options (from `@prop(options)`) to the appropriate place.
If custom types are used and they dont have `OptionsConstructor`, and an easy way to workaround this error is the following:
If custom types are used and they don't have `OptionsConstructor`, and an easy way to workaround this error is the following:
```ts
mongoose.Schema.Types.Custom.OptionsConstructor = {}; // only do this if really necessary
@ -288,7 +288,7 @@ Error Class: `AssertionFallbackError`
Details:
This Error should never show up, if it does report it
### PropOptions.discriminators dosnt support Arrays with more or less than 1 dimension [E020]
### PropOptions.discriminators doesn't support Arrays with more or less than 1 dimension [E020]
<span class="badge badge--warning">This Error got removed in 9.4.0</span>
@ -296,7 +296,7 @@ This Error should never show up, if it does report it
This Error got merged with [`E027`](#the-option-does-not-support-a-option-value-e027) in 9.4.0
:::
Error: `"PropOptions.discriminators" dosnt support Arrays higher and lower than 1 (got "${gotType.dim}" dimensions at "${name}.${key}") [E020]`
Error: `"PropOptions.discriminators" doesn't support Arrays higher and lower than 1 (got "${gotType.dim}" dimensions at "${name}.${key}") [E020]`
Error Class: `Error`
@ -315,7 +315,7 @@ class ErrorClass {
}
```
### PropOptions.ref dosnt support Arrays [E021]
### PropOptions.ref doesn't support Arrays [E021]
<span class="badge badge--warning">This Error got removed in 9.4.0</span>

@ -11,7 +11,7 @@ A: The original author szokodiakos (github name) [has abandoned the project](htt
### Is this Project still active?
A: Yes it is, but not on the main repository anymore because of [What happened to the original author?](#what-happened-to-the-original-author) and [Github Permissions](https://help.github.com/en/articles/permission-levels-for-a-user-account-repository) (TL;DR: a collaborator cannot add another collaborater, only the owner can)
A: Yes it is, but not on the main repository anymore because of [What happened to the original author?](#what-happened-to-the-original-author) and [Github Permissions](https://help.github.com/en/articles/permission-levels-for-a-user-account-repository) (TL;DR: a collaborator cannot add another collaborator, only the owner can)
### Why is the package now released in another package?
@ -20,7 +20,7 @@ A: Because of a Repository Switch ([reasons](#is-this-project-still-active)) and
### Why `@typegoose/typegoose`
A: Because I (hasezoey) don't have permissions over the old `typegoose` repository and I dont want to touch the old npm package. It is a typical forking and continuation of an OSS project.
A: Because I (hasezoey) don't have permissions over the old `typegoose` repository and I don't want to touch the old npm package. It is a typical forking and continuation of an OSS project.
## Functional

@ -37,7 +37,7 @@ import * as mongoose from 'mongoose';
import * as autopopulate from 'mongoose-autopopulate';
import { plugin, prop, Ref, getModelForClass } from '@typegoose/typegoose';
@plugin(autopopulate as any) // this is a dirty fix, because the types of this plugin dont work with "esModuleInterop: false"
@plugin(autopopulate as any) // this is a dirty fix, because the types of this plugin don't work with "esModuleInterop: false"
class SomeClass {
@prop({ autopopulate: true, ref: 'SomeReferencedClass' })
public populateField: Ref<SomeReferencedClass>;
@ -109,7 +109,7 @@ the user collection 10 times, extremely delaying the output of the query. Below
```ts
// the types of "autopopulate" may change depending on the tsconfig option "esModuleInterop"
@plugin(autopopulate as any) // this is a dirty fix, because the types of this plugin dont work
@plugin(autopopulate as any) // this is a dirty fix, because the types of this plugin don't work
class SomeClass {
@prop({ autopopulate: { maxDepth: 1 }, ref: 'SomeReferencedClass' })
public populateField: Ref<SomeReferencedClass>;

@ -22,7 +22,7 @@ npm install --save @deepkit/core@~1.0.1-alpha.52 @deepkit/type@~1.0.1-alpha.56
## Implementation
:::note
It is better to have [DTOs](https://en.wikipedia.org/wiki/Data_transfer_object) to separate your API logic (decorated with @deepkit/type decorators) from your Entities (decorated with Typgoose decorators). This may seem like extra code, verbosity and work, but it is smart, because it will allow you to change your API and Entities separate from each other.
It is better to have [DTOs](https://en.wikipedia.org/wiki/Data_transfer_object) to separate your API logic (decorated with @deepkit/type decorators) from your Entities (decorated with Typegoose decorators). This may seem like extra code, verbosity and work, but it is smart, because it will allow you to change your API and Entities separate from each other.
:::
Suppose you have this `Account` class decorated with `@deepkit/type`:
@ -91,7 +91,7 @@ You can then do, for example:
As you can see from these code examples, there is:
* an `access` or `grouping` (`@t.group(group)`) definition needed to ouput the required properties for any serializing or deserializing. The `@deepkit/type` author suggests not using groupings at all, as they cause `@deepkit/type`'s performance to deteriorate. [See Offical Documentation for Reference](https://deepkit.io/documentation/type/serialization#groups), official quote:
* an `access` or `grouping` (`@t.group(group)`) definition needed to output the required properties for any serializing or deserializing. The `@deepkit/type` author suggests not using groupings at all, as they cause `@deepkit/type`'s performance to deteriorate. [See Official Documentation for Reference](https://deepkit.io/documentation/type/serialization#groups), official quote:
> Note: Using grouped serialization is much slower than regular serialization. If performance is important, consider rearranging your data into multiple classes instead.
* a `Mongodb.ObjectId` decorator (`@t.mongoId`) is built into `@deepkit/type`'s decorators to handle the type conversion to string and back to a MongoId.
@ -131,7 +131,7 @@ import * as mongoose from 'mongoose';
// Shorten type
const ObjectId = mongoose.Types.ObjectId;
// Create a Custom Serializer to add custom transfrom functions to types
// Create a Custom Serializer to add custom transform functions to types
const mySerializer = new (class CustomSerializer extends jsonSerializer.fork('mySerializer') {})();
// Note: A custom Serializer has to be used, because the included "mongoId" "decorator" only works with "@deepkit/orm"

@ -39,7 +39,7 @@ class SomeClass {
<span class="badge badge--warning">This Section may be outdated</span>
Using babel as a TypeScript compiler is known to cause problems (like incorrect types) (see [`transpile-only`](#transpile-only)), it is recommened you use `tsc`, `ts-node` or `ts-jest` directly.
Using babel as a TypeScript compiler is known to cause problems (like incorrect types) (see [`transpile-only`](#transpile-only)), it is recommended you use `tsc`, `ts-node` or `ts-jest` directly.
If Babel is still needed, then read [Babel TypeScript preset](https://babeljs.io/docs/en/babel-preset-typescript) and install the following plugins:

@ -44,7 +44,7 @@ Otherwise, the functions still override the settings made in `modelOptions`
## Hooks
Hooks recieved a change (in 6.0.0-13) for the types to comply with the latest mongoose (5.6.8)
Hooks received a change (in 6.0.0-13) for the types to comply with the latest mongoose (5.6.8)
-> no workarounds or typedefs required anymore.
## Methods (staticMethod, instanceMethod, virtuals)

@ -35,7 +35,7 @@ All possible cache-maps that were in `data.ts` were refactored to be in the refl
## [IC] almost all "if-throw" blocks got replaced with "assertion" functions
Typescript 3.7 introduced a new type-keyword [`asserts`](https://devblogs.microsoft.com/typescript/announcing-typescript-3-7/#assertion-functions) and now almost every occurence has been replaced with a custom assertion function.
Typescript 3.7 introduced a new type-keyword [`asserts`](https://devblogs.microsoft.com/typescript/announcing-typescript-3-7/#assertion-functions) and now almost every occurrence has been replaced with a custom assertion function.
## [IC] The Testing Framework for Typegoose changed to Jest

@ -3,11 +3,11 @@ id: use-without-emitDecoratorMetadata
title: 'Use Without "emitDecoratorMetadata"'
---
Typegoose can be used without the option [`emitDecoratorMetadata`](https://www.typescriptlang.org/tsconfig#emitDecoratorMetadata), but it is generally recommeneded to enable it for auto-inferring from the typescript type.
Typegoose can be used without the option [`emitDecoratorMetadata`](https://www.typescriptlang.org/tsconfig#emitDecoratorMetadata), but it is generally recommended to enable it for auto-inferring from the typescript type.
## Advantages to "emitDecoratorMetadata"
When using `emitDecoratorMetadata`, it is not needed to be explicit about *everything*, like the following example would simply "compile" into the appropiate types.
When using `emitDecoratorMetadata`, it is not needed to be explicit about *everything*, like the following example would simply "compile" into the appropriate types.
:::info
Some Properties (like Arrays & Maps) need to be always explicit, see [`@prop` Array Options](../api/decorators/prop.md#array-options).

@ -17,7 +17,7 @@ export abstract class TimeStamps {
export interface Base<IDType extends RefType = Types.ObjectId> {
_id: IDType;
/**
* This getter/setter dosnt exist if "schemaOptions.id" being set to "false"
* This getter/setter doesn't exist if "schemaOptions.id" being set to "false"
*/
id: string;
}

@ -10,7 +10,7 @@ import type { DocumentType, EmptyVoidFn, HookOptionsEither, IHooksArray } from '
type NumberOrDocumentOrDocumentArray<T> = number | DocumentType<T> | DocumentType<T>[];
// i know that some events cannot be async (like "init"), but because they are unified into bigger types, i cannot change it
// I know that some events cannot be async (like "init"), but because they are unified into bigger types, I cannot change it
type ReturnVoid = void | Promise<void>;
type HookNextErrorFn = (err?: Error) => ReturnVoid;
@ -110,7 +110,7 @@ const hooks: Hooks = {
* Add a hook to the hooks Array
* @param target Target Class
* @param hookType What type is it
* @param args All Arguments, that should be passed-throught
* @param args All Arguments, that should be passed-through
*/
function addToHooks(target: any, hookType: 'pre' | 'post', args: any[]): void {
// Convert Method to array if only a string is provided

@ -51,7 +51,7 @@ export enum DecoratorKeys {
NestedDiscriminators = 'typegoose:nestedDiscriminators',
}
/** This Enum is meant for baseProp to decide for diffrent props (like if it is an arrayProp or prop or mapProp) */
/** This Enum is meant for baseProp to decide for different props (like if it is an arrayProp or prop or mapProp) */
export enum PropType {
ARRAY,
MAP,

@ -1,6 +1,6 @@
import { allVirtualoptions, toStringNoFail } from './utils';
// Note: dont forget to use "toStringNoFail" on values that are "unknown" or "any"
// Note: don't forget to use "toStringNoFail" on values that are "unknown" or "any"
export class InvalidTypeError extends Error {
constructor(targetName: string, key: string, Type: unknown) {
@ -110,7 +110,7 @@ export class OptionDoesNotSupportOptionError extends TypeError {
export class ResolveTypegooseNameError extends ReferenceError {
constructor(input: unknown) {
super(
'Input was not a string AND didnt have a .typegooseName function AND didnt have a .typegooseName string [E014]\n' +
"Input was not a string AND didn't have a .typegooseName function AND didn't have a .typegooseName string [E014]\n" +
`Value: "${toStringNoFail(input)}"`
);
}

@ -271,7 +271,7 @@ export function processProp(input: DecoratedPropertyMetadata): void {
const enumOption = rawOptions.enum;
if (!utils.isNullOrUndefined(enumOption)) {
// check if the supplied value is already "mongoose-consumeable"
// check if the supplied value is already "mongoose-consumable"
if (!Array.isArray(enumOption)) {
if (Type === String || Type === mongoose.Schema.Types.String) {
rawOptions.enum = Object.entries<string>(enumOption) // get all key-value pairs of the enum

@ -131,7 +131,7 @@ export function isString(Type: any): Type is string {
}
/**
* Generate the inital values for the property to be extended upon
* Generate the initial values for the property to be extended upon
* @param name Name of the current Model/Class
* @param key Key of the property
* @param proptype Type of the Property
@ -282,7 +282,7 @@ export function mergeMetadata<T = any>(key: DecoratorKeys, value: unknown, cl: A
}
/**
* Used for lodash customizer's (cloneWith, cloneDeepWith, mergeWith)
* Used for lodash customizers (cloneWith, cloneDeepWith, mergeWith)
* @param key the key of the current object
* @param val the value of the object that should get returned for "existingMongoose" & "existingConnection"
*/

@ -150,7 +150,7 @@ export function buildSchema<U extends AnyParamConstructor<any>>(
// iterate trough all parents
while (parentCtor?.name !== 'Object') {
// add lower classes (when extending) to the front of the arrray to be processed first
// add lower classes (when extending) to the front of the array to be processed first
parentClasses.unshift(parentCtor);
// set next parent
@ -172,7 +172,7 @@ export function buildSchema<U extends AnyParamConstructor<any>>(
/**
* Add a Class-Model Pair to the Typegoose Cache
* This can be used to add custom Models to Typegoose, with the type information of "cl"
* Note: no gurantee that the type information is fully correct when used manually
* Note: no guarrantee that the type information is fully correct when used manually
* @param model The Model to store
* @param cl The Class to store
* @param options Overwrite existingMongoose or existingConnection
@ -181,7 +181,7 @@ export function buildSchema<U extends AnyParamConstructor<any>>(
* class ClassName {}
*
* const schema = buildSchema(ClassName);
* // modifications to the schame can be done
* // modifications to the schema can be done
* const model = addModelToTypegoose(mongoose.model("Name", schema), ClassName);
* ```
*/

@ -26,7 +26,7 @@ export function isDocumentArray<T, S extends RefType>(
*/
export function isDocumentArray<T, S extends RefType>(docs: Ref<T, S>[] | undefined): docs is DocumentType<NonNullable<T>>[];
export function isDocumentArray(docs: Ref<any, any>[] | undefined): unknown {
// its "any" & "unkown" because this is not listed as an overload
// its "any" & "unknown" because this is not listed as an overload
return Array.isArray(docs) && docs.every((v) => isDocument(v));
}
@ -79,7 +79,7 @@ export function isRefTypeArray<T, S extends RefType>(
*/
export function isRefTypeArray<T, S extends RefType>(docs: Ref<T, S>[] | undefined, refType: AllowedRefTypes): docs is NonNullable<S>[];
export function isRefTypeArray(docs: Ref<any, any>[] | undefined, refType: AllowedRefTypes): unknown {
// its "any" & "unkown" because this is not listed as an overload
// its "any" & "unknown" because this is not listed as an overload
return Array.isArray(docs) && docs.every((v) => isRefType(v, refType));
}

@ -86,7 +86,7 @@ export interface BasePropOptions {
*/
allowMixed?: Severity;
/** Give the Property a default Value */
default?: mongoose.SchemaTypeOptions<any>['default']; // i know this one does not have much of an effect, because of "any"
default?: mongoose.SchemaTypeOptions<any>['default']; // I know this one does not have much of an effect, because of "any"
/** Give an Validator RegExp or Function */
validate?: mongoose.SchemaTypeOptions<any>['validate'];
/**
@ -96,7 +96,7 @@ export interface BasePropOptions {
unique?: mongoose.SchemaTypeOptions<any>['unique'];
/**
* Should this property have an index?
* Note: dont use this if you want to do an compound index
* Note: don't use this if you want to do an compound index
* @link https://docs.mongodb.com/manual/indexes
*/
index?: mongoose.SchemaTypeOptions<any>['index'];
@ -203,7 +203,7 @@ export interface BasePropOptions {
/**
* Set the Nested Discriminators
*
* Note: "_id: false" as an prop option dosnt work here
* Note: "_id: false" as an prop option doesn't work here
*
* Note: Custom Typegoose Option
*/
@ -600,7 +600,7 @@ export interface IObjectWithTypegooseName {
typegooseName: string;
}
/** For the types that error that seemingly dont have a prototype */
/** For the types that error that seemingly don't have a prototype */
export interface IPrototype {
prototype?: any;
}
@ -618,6 +618,6 @@ export interface GetTypeReturn {
/**
* This type is for lint error "ban-types" where "{}" would be used
* This type is seperate from "{@link KeyStringAny}" because it has a different meaning
* This type is separate from "{@link KeyStringAny}" because it has a different meaning
*/
export type BeAnObject = Record<string, any>;

@ -16,7 +16,7 @@ export class Profile {
discriminatorKey: 'role',
},
})
export class DisciminatedUser<T extends Profile = Profile> {
export class DiscriminatedUser<T extends Profile = Profile> {
@prop({ required: true, enum: ROLE })
public role?: ROLE; // optional because it will be automatically added
@ -24,7 +24,7 @@ export class DisciminatedUser<T extends Profile = Profile> {
public profile?: T;
}
export class Visitor extends DisciminatedUser {
export class Visitor extends DiscriminatedUser {
@prop()
public visitor?: string;
}
@ -34,7 +34,7 @@ export class DefaultProfile extends Profile {
public lastName?: string;
}
export class Default extends DisciminatedUser<DefaultProfile> {
export class Default extends DiscriminatedUser<DefaultProfile> {
@prop()
public default?: string;
@ -42,6 +42,6 @@ export class Default extends DisciminatedUser<DefaultProfile> {
public profile?: DefaultProfile;
}
export const DisciminatedUserModel = getModelForClass(DisciminatedUser);
export const VisitorModel = getDiscriminatorModelForClass(DisciminatedUserModel, Visitor, ROLE.VISITOR);
export const DefaultModel = getDiscriminatorModelForClass(DisciminatedUserModel, Default, ROLE.DEFAULT);
export const DiscriminatedUserModel = getModelForClass(DiscriminatedUser);
export const VisitorModel = getDiscriminatorModelForClass(DiscriminatedUserModel, Visitor, ROLE.VISITOR);
export const DefaultModel = getDiscriminatorModelForClass(DiscriminatedUserModel, Default, ROLE.DEFAULT);

@ -9,7 +9,7 @@ import { getModelForClass, isDocument, post, pre, prop } from '../../src/typegoo
})
@pre<Hook>(/^update/, function () {
if (Array.isArray(this)) {
this.forEach(async (v) => await v.update({ shape: 'REGEXP_PRE' })); // i know this is inefficient
this.forEach(async (v) => await v.update({ shape: 'REGEXP_PRE' })); // I know this is inefficient
} else {
this.update({ shape: 'REGEXP_PRE' });
}

@ -6,7 +6,7 @@ export class JobType {
public field!: string;
@prop({ required: true })
public salery!: number;
public salary!: number;
}
@modelOptions({ schemaOptions: { _id: false } })

@ -22,7 +22,7 @@ Object {
"job": Object {
"jobType": Object {
"field": "IT",
"salery": 5000,
"salary": 5000,
},
"position": "Lead",
"startedAt": Any<Date>,

@ -5,7 +5,7 @@ exports[`should error if 0 or less dimensions are given (createArrayFromDimensio
exports[`should error if 0 or less dimensions are given (createArrayFromDimensions) [RangeError] [E018] 2`] = `"\\"dim\\" needs to be higher than 0 (.) [E018]"`;
exports[`should error if a non-valid object is passed to "getClass" [ResolveTypegooseNameError] [E014] 1`] = `
"Input was not a string AND didnt have a .typegooseName function AND didnt have a .typegooseName string [E014]
"Input was not a string AND didn't have a .typegooseName function AND didn't have a .typegooseName string [E014]
Value: \\"undefined\\""
`;

@ -35,7 +35,7 @@ it(
title: 'Developer',
position: 'Lead',
jobType: {
salery: 5000,
salary: 5000,
field: 'IT',
},
},

@ -1,4 +1,4 @@
import { IndexWeights, IndexWeightsModel } from '../models/indexweigths';
import { IndexWeights, IndexWeightsModel } from '../models/indexweights';
import { RatingCar, RatingCarModel, RatingModel, RatingUser, RatingUserModel } from '../models/rating';
import { SelectModel, SelectStrings } from '../models/select';

@ -2,7 +2,7 @@ import { t, jsonSerializer } from '@deepkit/type';
import { DocumentType, getModelForClass, prop, mongoose } from '../../src/typegoose';
const ObjectId = mongoose.Types.ObjectId;
// Create a Custom Serializer to add custom transfrom functions to types
// Create a Custom Serializer to add custom transform functions to types
const mySerializer = new (class CustomSerializer extends jsonSerializer.fork('mySerializer') {})();
// Note: A custom Serializer has to be used, because the included "mongoId" "decorator" only works with "@deepkit/orm"
@ -147,7 +147,7 @@ describe('@deepkit/type transforms', () => {
const access = { groups: [Group.confidential, Group.public] };
// transform our "fake" incoming DTO to a Class instance
const incomingDataTransformedToClass = plainToClass(Account, origData, access);
// Strre the class object
// Store the class object
const createdDoc = await AccountModel.create(incomingDataTransformedToClass);
// retrieve the document
const docFound = await AccountModel.findById(createdDoc._id).orFail().exec();

@ -14,7 +14,7 @@ import {
Ref,
} from '../../src/typegoose';
import { DisAbove, DisAboveModel, DisMain, DisMainModel } from '../models/discriminators';
import { Default, DefaultModel, DisciminatedUserModel, ROLE, Visitor, VisitorModel } from '../models/discriminatorsWithGenerics';
import { Default, DefaultModel, DiscriminatedUserModel, ROLE, Visitor, VisitorModel } from '../models/discriminatorsWithGenerics';
it('should make use of discriminators', async () => {
const disMainDoc = await DisMainModel.create({ main1: 'hello DMM' } as DisMain);
@ -44,7 +44,7 @@ it('"getDiscriminatorModelForClass" should return the same model if already defi
describe('Generic Discriminators', () => {
it('should use DefaultModel when setting role to "ROLE.DEFAULT"', async () => {
const instance: DocumentType<Default> = await DisciminatedUserModel.create({
const instance: DocumentType<Default> = await DiscriminatedUserModel.create({
role: ROLE.DEFAULT,
visitor: 'sth',
default: 'sth',
@ -74,7 +74,7 @@ describe('Generic Discriminators', () => {
});
it('should use VisitorModel when setting role to "ROLE.VISITOR"', async () => {
const instance: DocumentType<Visitor> = await DisciminatedUserModel.create({
const instance: DocumentType<Visitor> = await DiscriminatedUserModel.create({
role: ROLE.VISITOR,
visitor: 'sth',
default: 'sth',

@ -83,7 +83,7 @@ it('should properly set Decimal128, ObjectID types to field', () => {
expect((CarModel.schema as any).paths.someId.instance).toEqual('ObjectID');
});
// faild validation will need to be checked
// failed validation will need to be checked
it('should validate Decimal128', async () => {
expect.assertions(3);
try {

@ -160,7 +160,7 @@ it('should work with QueryMethod post "this" [typegoose/typegoose#694]', () => {
// @ts-expect-error The following will error in typescript, because it *should* always contain only one argument, but may not actually be there
assertion(args.length === 0);
})
// the following call should trigger the "this, error, result" overload, but does not, i dont know why
// the following call should trigger the "this, error, result" overload, but does not, I don't know why
// @post('findOneAndUpdate', function error(error, result, ...args) {
// // this function should not be triggered by this test, but still includes it for property (types) testing
// assertion(!isNullOrUndefined(this));

@ -23,7 +23,7 @@ it('should set all parent props for nested schemas', async () => {
expect(instance.mainGarage!.slotsForCars).toEqual(3);
expect(instance.mainGarage!.width).toEqual(100);
// this has an any type assertion, because it shouldnt exists on this type, what is tested here
// this has an any type assertion, because it shouldn't exists on this type, what is tested here
expect((instance.mainGarage as any).doors).toBeUndefined();
// sanity check
@ -44,7 +44,7 @@ it('should set all parent props for nested array items', async () => {
const firstGarage = instance.garagesInArea!.pop();
expect(firstGarage!.slotsForCars).toEqual(2);
expect(firstGarage!.width).toEqual(100);
// this has an any type assertion, because it shouldnt exists on this type, what is tested here
// this has an any type assertion, because it shouldn't exists on this type, what is tested here
expect((firstGarage as any).doors).toBeUndefined();
// sanity check

@ -46,7 +46,7 @@ describe('existingMongoose & existingConnection', () => {
});
it('should merge existingConnection correctly (overwrite)', () => {
// @ts-expect-error because "hello" dosnt exist in "existingConnection"
// @ts-expect-error because "hello" doesn't exist in "existingConnection"
@modelOptions({ existingConnection: { hello: 1 } })
class Dummy {}

@ -9,7 +9,7 @@ it('should make use of nested-discriminators [typegoose/typegoose#25]', async ()
@modelOptions({
schemaOptions: {
discriminatorKey: 'type',
// set to "throw" that if the discriminators dont get applied it fails instead of silently discarding non-existent values
// set to "throw" that if the discriminators don't get applied it fails instead of silently discarding non-existent values
strict: 'throw',
_id: false,
},
@ -77,7 +77,7 @@ it('should make use of nested-discriminators (options as object) [typegoose/type
@modelOptions({
schemaOptions: {
discriminatorKey: 'type',
// set to "throw" that if the discriminators dont get applied it fails instead of silently discarding non-existent values
// set to "throw" that if the discriminators don't get applied it fails instead of silently discarding non-existent values
// strict: 'throw',
_id: false,
},

@ -42,7 +42,7 @@ it('should be possible to overwrite an existing model', () => {
});
it('should not error if model did not exist in "models" map', () => {
deleteModel('DefinetlyNotExistingModel');
deleteModel('DefinitelyNotExistingModel');
});
it('should make use of "deleteModelWithClass"', () => {