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: 5528a6428bb08091c03d868e249c2e5a30144a71
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 6,824 additions and 3,004 deletions.
  1. +232 −0 .eslintrc.js
  2. +0 −194 .eslintrc.json
  3. +1 −1 .github/ISSUE_TEMPLATE/bug.yml
  4. +3 −9 .github/workflows/benchmark.yml
  5. +1 −1 .github/workflows/codeql.yml
  6. +3 −2 .github/workflows/documentation.yml
  7. +1 −1 .github/workflows/stale.yml
  8. +20 −33 .github/workflows/test.yml
  9. +2 −2 .github/workflows/tidelift-alignment.yml
  10. +4 −4 .github/workflows/tsd.yml
  11. +6 −1 .gitignore
  12. +229 −0 CHANGELOG.md
  13. +17 −17 README.md
  14. +70 −38 benchmarks/get.js
  15. +55 −0 benchmarks/mapOfSubdocs.js
  16. +4 −1 benchmarks/typescript/simple/package.json
  17. +4 −4 docs/advanced_schemas.md
  18. +7 −7 docs/api.pug
  19. +11 −11 docs/api_split.pug
  20. +31 −31 docs/async-await.md
  21. +6 −6 docs/change-streams.md
  22. +34 −0 docs/check-version.md
  23. +1 −1 docs/compatibility.md
  24. +26 −26 docs/connections.md
  25. +0 −3 docs/contributing.md
  26. +4 −4 docs/customschematypes.md
  27. +10 −10 docs/defaults.md
  28. +4 −4 docs/deprecations.md
  29. +25 −12 docs/discriminators.md
  30. +6 −6 docs/documents.md
  31. +3 −3 docs/enterprise.md
  32. +12 −10 docs/faq.md
  33. +8 −14 docs/geojson.md
  34. +148 −144 docs/guide.md
  35. +9 −6 docs/guides.md
  36. +14 −13 docs/includes/favicon.pug
  37. +1 −1 docs/includes/native.pug
  38. +4 −0 docs/incompatible_packages.md
  39. +6 −6 docs/index.md
  40. +6 −0 docs/jest.md
  41. +29 −28 docs/js/api-bold-current-nav.js
  42. +0 −6 docs/js/cookies.min.js
  43. +11 −10 docs/js/mobile-navbar-toggle.js
  44. +18 −10 docs/js/navbar-search.js
  45. +19 −14 docs/js/search.js
  46. +0 −4 docs/js/zepto.min.js
  47. +3 −13 docs/lambda.md
  48. +71 −65 docs/layout.pug
  49. +14 −6 docs/loadSponsorData.js
  50. +53 −28 docs/middleware.md
  51. +91 −89 docs/migrating_to_5.md
  52. +70 −40 docs/migrating_to_6.md
  53. +6 −6 docs/migration.md
  54. +8 −8 docs/models.md
  55. +12 −12 docs/plugins.md
  56. +49 −48 docs/populate.md
  57. +0 −8 docs/prior.pug
  58. +10 −10 docs/promises.md
  59. +101 −18 docs/queries.md
  60. +90 −51 docs/schematypes.md
  61. +3 −3 docs/search.pug
  62. +107 −40 docs/source/api.js
  63. +5 −5 docs/source/home.js
  64. +75 −43 docs/source/index.js
  65. +8 −0 docs/source/tutorials.js
  66. +7 −0 docs/source/typescript.js
  67. +29 −0 docs/source/utils.js
  68. +0 −29 docs/splitApiDocs.js
  69. +3 −3 docs/sponsors.pug
  70. +21 −24 docs/subdocs.md
  71. +9 −9 docs/timestamps.md
  72. +26 −13 docs/transactions.md
  73. +3 −3 docs/tutorials/custom-casting.md
  74. +6 −6 docs/tutorials/dates.md
  75. +9 −9 docs/tutorials/findoneandupdate.md
  76. +23 −14 docs/tutorials/getters-setters.md
  77. +0 −15 docs/tutorials/index.js
  78. +11 −11 docs/tutorials/lean.md
  79. +10 −12 docs/tutorials/query_casting.md
  80. +4 −5 docs/tutorials/ssl.md
  81. +6 −6 docs/tutorials/virtuals.md
  82. +5 −5 docs/typescript.md
  83. +0 −14 docs/typescript/index.js
  84. +4 −4 docs/typescript/query-helpers.md
  85. +21 −12 docs/typescript/schemas.md
  86. +3 −2 docs/typescript/statics-and-methods.md
  87. +2 −2 docs/typescript/statics.md
  88. +48 −7 docs/typescript/virtuals.md
  89. +40 −39 docs/validation.md
  90. +27 −0 docs/version-support.md
  91. +1 −1 examples/aggregate/aggregate.js
  92. +1 −1 examples/geospatial/geospatial.js
  93. +2 −3 index.pug
  94. +42 −43 lib/aggregate.js
  95. +2 −1 lib/cast.js
  96. +16 −6 lib/connection.js
  97. +2 −2 lib/cursor/AggregationCursor.js
  98. +16 −1 lib/cursor/ChangeStream.js
  99. +3 −2 lib/cursor/QueryCursor.js
  100. +170 −90 lib/document.js
  101. +48 −12 lib/drivers/node-mongodb-native/collection.js
  102. +21 −10 lib/error/index.js
  103. +1 −1 lib/error/objectParameter.js
  104. +1 −1 lib/error/serverSelection.js
  105. +2 −1 lib/helpers/discriminator/mergeDiscriminatorSchema.js
  106. +17 −4 lib/helpers/document/applyDefaults.js
  107. +11 −1 lib/helpers/document/compile.js
  108. +3 −0 lib/helpers/model/discriminator.js
  109. +0 −39 lib/helpers/path/flattenObjectWithDottedPaths.js
  110. +14 −3 lib/helpers/populate/assignRawDocsToIdStructure.js
  111. +11 −0 lib/helpers/populate/createPopulateQueryFilter.js
  112. +15 −11 lib/helpers/printJestWarning.js
  113. +4 −3 lib/helpers/processConnectionOptions.js
  114. +1 −0 lib/helpers/projection/hasIncludedChildren.js
  115. +8 −0 lib/helpers/projection/isNestedProjection.js
  116. +1 −1 lib/helpers/query/cast$expr.js
  117. +1 −10 lib/helpers/query/castUpdate.js
  118. +12 −0 lib/helpers/schema/applyBuiltinPlugins.js
  119. +0 −1 lib/helpers/schema/getPath.js
  120. +40 −22 lib/index.js
  121. +256 −113 lib/model.js
  122. +0 −28 lib/plugins/clearValidating.js
  123. +7 −0 lib/plugins/index.js
  124. +206 −198 lib/query.js
  125. +112 −9 lib/schema.js
  126. +100 −0 lib/schema/DocumentArrayElement.js
  127. +7 −5 lib/schema/SubdocumentPath.js
  128. +8 −8 lib/schema/array.js
  129. +13 −32 lib/schema/documentarray.js
  130. +1 −1 lib/schema/operators/text.js
  131. +17 −12 lib/schema/uuid.js
  132. +7 −4 lib/schematype.js
  133. +1 −1 lib/types/ArraySubdocument.js
  134. +1 −1 lib/types/array/index.js
  135. +12 −13 lib/types/array/methods/index.js
  136. +1 −1 lib/types/buffer.js
  137. +25 −11 lib/types/map.js
  138. +3 −3 lib/types/subdocument.js
  139. +2 −0 lib/utils.js
  140. +1 −1 lib/virtualtype.js
  141. +41 −28 package.json
  142. +49 −26 docs/search.js → scripts/generateSearch.js
  143. +11 −2 scripts/static.js
  144. +15 −0 scripts/tsc-diagnostics-check.js
  145. +230 −35 scripts/website.js
  146. +2 −1 test/.eslintrc.yml
  147. +1 −0 test/aggregate.test.js
  148. +9 −6 test/collection.capped.test.js
  149. +26 −3 test/collection.test.js
  150. +117 −36 test/connection.test.js
  151. +27 −31 test/deno.js
  152. +54 −0 test/deno_mocha.js
  153. +5 −5 test/docs/asyncIterator.test.js
  154. +5 −1 test/docs/cast.test.js
  155. +5 −4 test/docs/date.test.js
  156. +26 −3 test/docs/debug.test.js
  157. +2 −2 test/docs/defaults.test.js
  158. +39 −3 test/docs/discriminators.test.js
  159. +10 −6 test/docs/findoneandupdate.test.js
  160. +12 −5 test/docs/getters-setters.test.js
  161. +5 −1 test/docs/lean.test.js
  162. +24 −24 test/docs/promises.test.js
  163. +2 −2 test/docs/schemas.test.js
  164. +22 −23 test/docs/transactions.test.js
  165. +4 −4 test/docs/validation.test.js
  166. +8 −5 test/docs/virtuals.test.js
  167. +53 −0 test/document.modified.test.js
  168. +502 −7 test/document.test.js
  169. +2 −1 test/errors.validation.test.js
  170. +2 −0 test/helpers/clone.test.js
  171. +4 −1 test/helpers/indexes.getRelatedIndexes.test.js
  172. +2 −0 test/helpers/indexes.isIndexEqual.test.js
  173. +2 −0 test/helpers/isMongooseObject.test.js
  174. +2 −0 test/helpers/isSimpleValidator.test.js
  175. +3 −2 test/helpers/populate.getSchemaTypes.test.js
  176. +3 −1 test/helpers/populate.getVirtual.test.js
  177. +3 −1 test/helpers/projection.applyProjection.test.js
  178. +44 −5 test/index.test.js
  179. +6 −0 test/mocha-fixtures.js
  180. +21 −0 test/model.discriminator.querying.test.js
  181. +93 −0 test/model.discriminator.test.js
  182. +0 −1 test/model.findOneAndReplace.test.js
  183. +10 −5 test/model.findOneAndUpdate.test.js
  184. +66 −0 test/model.indexes.test.js
  185. +110 −0 test/model.populate.test.js
  186. +290 −212 test/model.test.js
  187. +31 −2 test/model.update.test.js
  188. +147 −0 test/model.validate.test.js
  189. +79 −0 test/model.watch.test.js
  190. +24 −0 test/query.cursor.test.js
  191. +0 −2 test/query.middleware.test.js
  192. +82 −4 test/query.test.js
  193. +9 −0 test/schema.documentarray.test.js
  194. +160 −10 test/schema.test.js
  195. +50 −2 test/schema.uuid.test.js
  196. +68 −5 test/schema.validation.test.js
  197. +18 −0 test/types.documentarray.test.js
  198. +1 −0 test/types.map.test.js
  199. +8 −15 test/types.subdocument.test.js
  200. +2 −0 test/types/.eslintrc.yml
  201. +5 −5 test/types/PipelineStage.test.ts
  202. +6 −1 test/types/aggregate.test.ts
  203. +7 −0 test/types/expressions.test.ts
  204. +12 −2 test/types/lean.test.ts
  205. +57 −3 test/types/models.test.ts
  206. +17 −0 test/types/mongo.test.ts
  207. +30 −0 test/types/populate.test.ts
  208. +9 −0 test/types/queries.test.ts
  209. +8 −0 test/types/querycursor.test.ts
  210. +142 −0 test/types/schema.test.ts
  211. +19 −0 test/types/schemaTypeOptions.test.ts
  212. +32 −0 test/types/subdocuments.test.ts
  213. +2 −2 test/virtualtype.test.js
  214. +7 −65 types/aggregate.d.ts
  215. +9 −0 types/augmentations.d.ts
  216. +4 −4 types/connection.d.ts
  217. +4 −4 types/cursor.d.ts
  218. +1 −1 types/document.d.ts
  219. +5 −0 types/error.d.ts
  220. +154 −153 types/expressions.d.ts
  221. +13 −9 types/index.d.ts
  222. +38 −13 types/inferschematype.d.ts
  223. +38 −11 types/models.d.ts
  224. +8 −1 types/mongooseoptions.d.ts
  225. +39 −35 types/pipelinestage.d.ts
  226. +11 −11 types/query.d.ts
  227. +6 −0 types/schemaoptions.d.ts
  228. +43 −1 types/schematypes.d.ts
  229. +4 −4 types/session.d.ts
  230. +1 −1 types/types.d.ts
  231. +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