Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Automattic/mongoose
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8123ef39830bf3f5ee27f07029765d00ebc1bdd5
Choose a base ref
...
head repository: Automattic/mongoose
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c00a715e97c6437a5ff1a503c2a50ebd0df2ba47
Choose a head ref
Loading
Showing with 5,679 additions and 2,810 deletions.
  1. +232 −0 .eslintrc.js
  2. +0 −194 .eslintrc.json
  3. +2 −2 .github/workflows/benchmark.yml
  4. +1 −1 .github/workflows/codeql.yml
  5. +3 −2 .github/workflows/documentation.yml
  6. +20 −33 .github/workflows/test.yml
  7. +2 −2 .github/workflows/tidelift-alignment.yml
  8. +4 −4 .github/workflows/tsd.yml
  9. +6 −1 .gitignore
  10. +190 −0 CHANGELOG.md
  11. +17 −17 README.md
  12. +70 −38 benchmarks/get.js
  13. +55 −0 benchmarks/mapOfSubdocs.js
  14. +4 −4 docs/advanced_schemas.md
  15. +7 −7 docs/api.pug
  16. +11 −11 docs/api_split.pug
  17. +31 −31 docs/async-await.md
  18. +6 −6 docs/change-streams.md
  19. +34 −0 docs/check-version.md
  20. +1 −1 docs/compatibility.md
  21. +26 −26 docs/connections.md
  22. +0 −3 docs/contributing.md
  23. +4 −4 docs/customschematypes.md
  24. +10 −10 docs/defaults.md
  25. +4 −4 docs/deprecations.md
  26. +11 −11 docs/discriminators.md
  27. +6 −6 docs/documents.md
  28. +3 −3 docs/enterprise.md
  29. +12 −10 docs/faq.md
  30. +8 −14 docs/geojson.md
  31. +148 −144 docs/guide.md
  32. +9 −6 docs/guides.md
  33. +14 −13 docs/includes/favicon.pug
  34. +1 −1 docs/includes/native.pug
  35. +6 −6 docs/index.md
  36. +6 −0 docs/jest.md
  37. +29 −28 docs/js/api-bold-current-nav.js
  38. +0 −6 docs/js/cookies.min.js
  39. +11 −10 docs/js/mobile-navbar-toggle.js
  40. +6 −7 docs/js/navbar-search.js
  41. +17 −16 docs/js/search.js
  42. +0 −4 docs/js/zepto.min.js
  43. +3 −13 docs/lambda.md
  44. +71 −65 docs/layout.pug
  45. +14 −6 docs/loadSponsorData.js
  46. +29 −28 docs/middleware.md
  47. +91 −89 docs/migrating_to_5.md
  48. +51 −40 docs/migrating_to_6.md
  49. +6 −6 docs/migration.md
  50. +8 −8 docs/models.md
  51. +12 −12 docs/plugins.md
  52. +49 −48 docs/populate.md
  53. +0 −8 docs/prior.pug
  54. +10 −10 docs/promises.md
  55. +27 −27 docs/queries.md
  56. +88 −48 docs/schematypes.md
  57. +3 −3 docs/search.pug
  58. +107 −40 docs/source/api.js
  59. +5 −5 docs/source/home.js
  60. +75 −44 docs/source/index.js
  61. +8 −0 docs/source/tutorials.js
  62. +7 −0 docs/source/typescript.js
  63. +29 −0 docs/source/utils.js
  64. +0 −29 docs/splitApiDocs.js
  65. +3 −3 docs/sponsors.pug
  66. +21 −24 docs/subdocs.md
  67. +9 −9 docs/timestamps.md
  68. +26 −13 docs/transactions.md
  69. +3 −3 docs/tutorials/custom-casting.md
  70. +6 −6 docs/tutorials/dates.md
  71. +9 −9 docs/tutorials/findoneandupdate.md
  72. +23 −14 docs/tutorials/getters-setters.md
  73. +0 −15 docs/tutorials/index.js
  74. +10 −10 docs/tutorials/lean.md
  75. +10 −12 docs/tutorials/query_casting.md
  76. +4 −5 docs/tutorials/ssl.md
  77. +6 −6 docs/tutorials/virtuals.md
  78. +5 −5 docs/typescript.md
  79. +0 −14 docs/typescript/index.js
  80. +4 −4 docs/typescript/query-helpers.md
  81. +6 −6 docs/typescript/schemas.md
  82. +3 −2 docs/typescript/statics-and-methods.md
  83. +2 −2 docs/typescript/statics.md
  84. +5 −5 docs/typescript/virtuals.md
  85. +40 −39 docs/validation.md
  86. +27 −0 docs/version-support.md
  87. +1 −1 examples/aggregate/aggregate.js
  88. +1 −1 examples/geospatial/geospatial.js
  89. +2 −3 index.pug
  90. +42 −43 lib/aggregate.js
  91. +2 −1 lib/cast.js
  92. +16 −6 lib/connection.js
  93. +2 −2 lib/cursor/AggregationCursor.js
  94. +16 −1 lib/cursor/ChangeStream.js
  95. +3 −2 lib/cursor/QueryCursor.js
  96. +168 −90 lib/document.js
  97. +25 −6 lib/drivers/node-mongodb-native/collection.js
  98. +21 −10 lib/error/index.js
  99. +1 −1 lib/error/objectParameter.js
  100. +1 −1 lib/error/serverSelection.js
  101. +2 −1 lib/helpers/discriminator/mergeDiscriminatorSchema.js
  102. +17 −4 lib/helpers/document/applyDefaults.js
  103. +11 −1 lib/helpers/document/compile.js
  104. +0 −39 lib/helpers/path/flattenObjectWithDottedPaths.js
  105. +15 −11 lib/helpers/printJestWarning.js
  106. +4 −3 lib/helpers/processConnectionOptions.js
  107. +1 −0 lib/helpers/projection/hasIncludedChildren.js
  108. +8 −0 lib/helpers/projection/isNestedProjection.js
  109. +1 −1 lib/helpers/query/cast$expr.js
  110. +1 −12 lib/helpers/query/castUpdate.js
  111. +0 −1 lib/helpers/schema/getPath.js
  112. +38 −10 lib/index.js
  113. +212 −113 lib/model.js
  114. +206 −198 lib/query.js
  115. +106 −8 lib/schema.js
  116. +100 −0 lib/schema/DocumentArrayElement.js
  117. +7 −5 lib/schema/SubdocumentPath.js
  118. +8 −8 lib/schema/array.js
  119. +13 −32 lib/schema/documentarray.js
  120. +1 −1 lib/schema/operators/text.js
  121. +17 −12 lib/schema/uuid.js
  122. +7 −4 lib/schematype.js
  123. +1 −1 lib/types/ArraySubdocument.js
  124. +1 −1 lib/types/array/index.js
  125. +12 −13 lib/types/array/methods/index.js
  126. +1 −1 lib/types/buffer.js
  127. +25 −11 lib/types/map.js
  128. +3 −3 lib/types/subdocument.js
  129. +2 −0 lib/utils.js
  130. +1 −1 lib/virtualtype.js
  131. +37 −22 package.json
  132. +34 −25 docs/search.js → scripts/generateSearch.js
  133. +11 −2 scripts/static.js
  134. +230 −35 scripts/website.js
  135. +2 −1 test/.eslintrc.yml
  136. +1 −0 test/aggregate.test.js
  137. +9 −10 test/collection.capped.test.js
  138. +23 −9 test/collection.test.js
  139. +60 −23 test/connection.test.js
  140. +27 −31 test/deno.js
  141. +54 −0 test/deno_mocha.js
  142. +5 −5 test/docs/asyncIterator.test.js
  143. +2 −2 test/docs/cast.test.js
  144. +2 −2 test/docs/date.test.js
  145. +22 −4 test/docs/debug.test.js
  146. +2 −2 test/docs/defaults.test.js
  147. +5 −5 test/docs/discriminators.test.js
  148. +7 −7 test/docs/findoneandupdate.test.js
  149. +9 −6 test/docs/getters-setters.test.js
  150. +3 −3 test/docs/lean.test.js
  151. +24 −24 test/docs/promises.test.js
  152. +2 −2 test/docs/schemas.test.js
  153. +22 −23 test/docs/transactions.test.js
  154. +4 −4 test/docs/validation.test.js
  155. +5 −6 test/docs/virtuals.test.js
  156. +53 −0 test/document.modified.test.js
  157. +502 −7 test/document.test.js
  158. +32 −0 test/index.test.js
  159. +6 −0 test/mocha-fixtures.js
  160. +21 −0 test/model.discriminator.querying.test.js
  161. +69 −0 test/model.discriminator.test.js
  162. +0 −1 test/model.findOneAndReplace.test.js
  163. +10 −0 test/model.findOneAndUpdate.test.js
  164. +66 −0 test/model.indexes.test.js
  165. +60 −0 test/model.populate.test.js
  166. +224 −106 test/model.test.js
  167. +31 −2 test/model.update.test.js
  168. +79 −0 test/model.watch.test.js
  169. +24 −0 test/query.cursor.test.js
  170. +0 −6 test/query.middleware.test.js
  171. +79 −11 test/query.test.js
  172. +159 −9 test/schema.test.js
  173. +50 −2 test/schema.uuid.test.js
  174. +68 −5 test/schema.validation.test.js
  175. +18 −0 test/types.documentarray.test.js
  176. +1 −0 test/types.map.test.js
  177. +8 −15 test/types.subdocument.test.js
  178. +2 −0 test/types/.eslintrc.yml
  179. +5 −5 test/types/PipelineStage.test.ts
  180. +7 −0 test/types/expressions.test.ts
  181. +1 −1 test/types/lean.test.ts
  182. +57 −3 test/types/models.test.ts
  183. +17 −0 test/types/mongo.test.ts
  184. +30 −0 test/types/populate.test.ts
  185. +8 −0 test/types/querycursor.test.ts
  186. +32 −0 test/types/subdocuments.test.ts
  187. +2 −2 test/virtualtype.test.js
  188. +4 −67 types/aggregate.d.ts
  189. +9 −0 types/augmentations.d.ts
  190. +4 −4 types/connection.d.ts
  191. +4 −4 types/cursor.d.ts
  192. +1 −1 types/document.d.ts
  193. +5 −0 types/error.d.ts
  194. +154 −153 types/expressions.d.ts
  195. +9 −6 types/index.d.ts
  196. +38 −11 types/models.d.ts
  197. +8 −1 types/mongooseoptions.d.ts
  198. +39 −35 types/pipelinestage.d.ts
  199. +10 −10 types/query.d.ts
  200. +1 −1 types/schematypes.d.ts
  201. +4 −4 types/session.d.ts
  202. +1 −1 types/types.d.ts
  203. +1 −0 types/validation.d.ts
232 changes: 232 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
'use strict';

module.exports = {
extends: [
'eslint:recommended'
],
ignorePatterns: [
'tools',
'dist',
'website.js',
'test/files/*',
'benchmarks',
'*.min.js',
'docs/js/native.js'
],
overrides: [
{
files: [
'**/*.{ts,tsx}',
'**/*.md/*.ts',
'**/*.md/*.typescript'
],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended'
],
plugins: [
'@typescript-eslint'
],
rules: {
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-empty-function': 'off',
'spaced-comment': [
'error',
'always',
{
block: {
markers: [
'!'
],
balanced: true
},
markers: [
'/'
]
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/indent': [
'warn',
2,
{
SwitchCase: 1,
ignoredNodes: ['TSTypeParameterInstantiation']
}
],
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/brace-style': 'error',
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/object-curly-spacing': [
'error',
'always'
],
'@typescript-eslint/semi': 'error',
'@typescript-eslint/space-before-function-paren': [
'error',
'never'
],
'@typescript-eslint/space-infix-ops': 'off'
}
},
{
files: [
'docs/js/**/*.js'
],
env: {
node: false,
browser: true
}
}
// // eslint-plugin-markdown has been disabled because of out-standing issues, see https://github.com/eslint/eslint-plugin-markdown/issues/214
// {
// files: ['**/*.md'],
// processor: 'markdown/markdown'
// },
// {
// files: ['**/*.md/*.js', '**/*.md/*.javascript', '**/*.md/*.ts', '**/*.md/*.typescript'],
// parserOptions: {
// ecmaFeatures: {
// impliedStrict: true
// },
// sourceType: 'module', // required to allow "import" statements
// ecmaVersion: 'latest' // required to allow top-level await
// },
// rules: {
// 'no-undef': 'off',
// 'no-unused-expressions': 'off',
// 'no-unused-vars': 'off',
// 'no-redeclare': 'off',
// '@typescript-eslint/no-redeclare': 'off'
// }
// }
],
plugins: [
'mocha-no-only'
// 'markdown'
],
parserOptions: {
ecmaVersion: 2020
},
env: {
node: true,
es6: true
},
rules: {
'comma-style': 'error',
indent: [
'error',
2,
{
SwitchCase: 1,
VariableDeclarator: 2
}
],
'keyword-spacing': 'error',
'no-whitespace-before-property': 'error',
'no-buffer-constructor': 'warn',
'no-console': 'off',
'no-constant-condition': 'off',
'no-multi-spaces': 'error',
'func-call-spacing': 'error',
'no-trailing-spaces': 'error',
'no-undef': 'error',
'no-unneeded-ternary': 'error',
'no-const-assign': 'error',
'no-useless-rename': 'error',
'no-dupe-keys': 'error',
'space-in-parens': [
'error',
'never'
],
'spaced-comment': [
'error',
'always',
{
block: {
markers: [
'!'
],
balanced: true
}
}
],
'key-spacing': [
'error',
{
beforeColon: false,
afterColon: true
}
],
'comma-spacing': [
'error',
{
before: false,
after: true
}
],
'array-bracket-spacing': 1,
'arrow-spacing': [
'error',
{
before: true,
after: true
}
],
'object-curly-spacing': [
'error',
'always'
],
'comma-dangle': [
'error',
'never'
],
'no-unreachable': 'error',
quotes: [
'error',
'single'
],
'quote-props': [
'error',
'as-needed'
],
semi: 'error',
'no-extra-semi': 'error',
'semi-spacing': 'error',
'no-spaced-func': 'error',
'no-throw-literal': 'error',
'space-before-blocks': 'error',
'space-before-function-paren': [
'error',
'never'
],
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'no-var': 'warn',
'prefer-const': 'warn',
strict: [
'error',
'global'
],
'no-restricted-globals': [
'error',
{
name: 'context',
message: 'Don\'t use Mocha\'s global context'
}
],
'no-prototype-builtins': 'off',
'mocha-no-only/mocha-no-only': [
'error'
],
'no-empty': 'off',
'eol-last': 'warn',
'no-multiple-empty-lines': ['warn', { max: 2 }]
}
};
Loading