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: 695d73a9c60ea17e74490f47a6c070e8573a8606
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 9,334 additions and 3,896 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. +36 −21 .github/workflows/test.yml
  9. +2 −2 .github/workflows/tidelift-alignment.yml
  10. +5 −5 .github/workflows/tsd.yml
  11. +6 −1 .gitignore
  12. +3 −1 .npmignore
  13. +310 −0 CHANGELOG.md
  14. +10 −8 CONTRIBUTING.md
  15. +43 −22 README.md
  16. +2 −2 benchmarks/benchjs/delete.js
  17. +2 −2 benchmarks/benchjs/insert.js
  18. +2 −2 benchmarks/benchjs/multiop.js
  19. +1 −1 benchmarks/benchjs/population.js
  20. +2 −2 benchmarks/benchjs/read.js
  21. +2 −2 benchmarks/benchjs/update.js
  22. +70 −38 benchmarks/get.js
  23. +55 −0 benchmarks/mapOfSubdocs.js
  24. +1 −1 benchmarks/mem.js
  25. +1 −1 benchmarks/populate.js
  26. +4 −1 benchmarks/typescript/simple/package.json
  27. +4 −4 docs/advanced_schemas.md
  28. +7 −7 docs/api.pug
  29. +11 −11 docs/api_split.pug
  30. +35 −35 docs/async-await.md
  31. +8 −8 docs/change-streams.md
  32. +34 −0 docs/check-version.md
  33. +1 −1 docs/compatibility.md
  34. +46 −47 docs/connections.md
  35. +0 −3 docs/contributing.md
  36. +4 −4 docs/customschematypes.md
  37. +10 −10 docs/defaults.md
  38. +4 −4 docs/deprecations.md
  39. +25 −12 docs/discriminators.md
  40. +17 −17 docs/documents.md
  41. +3 −3 docs/enterprise.md
  42. +18 −16 docs/faq.md
  43. +10 −16 docs/geojson.md
  44. +202 −186 docs/guide.md
  45. +49 −45 docs/guides.md
  46. +14 −13 docs/includes/favicon.pug
  47. +1 −1 docs/includes/native.pug
  48. +4 −0 docs/incompatible_packages.md
  49. +13 −13 docs/index.md
  50. +8 −2 docs/jest.md
  51. +29 −28 docs/js/api-bold-current-nav.js
  52. +0 −6 docs/js/cookies.min.js
  53. +11 −10 docs/js/mobile-navbar-toggle.js
  54. +18 −10 docs/js/navbar-search.js
  55. +19 −14 docs/js/search.js
  56. +0 −4 docs/js/zepto.min.js
  57. +3 −13 docs/lambda.md
  58. +71 −65 docs/layout.pug
  59. +20 −9 docs/loadSponsorData.js
  60. +39 −0 docs/lodash.md
  61. +113 −68 docs/middleware.md
  62. +95 −93 docs/migrating_to_5.md
  63. +72 −42 docs/migrating_to_6.md
  64. +6 −6 docs/migration.md
  65. +19 −18 docs/models.md
  66. +15 −15 docs/plugins.md
  67. +64 −63 docs/populate.md
  68. +0 −8 docs/prior.pug
  69. +13 −13 docs/promises.md
  70. +127 −43 docs/queries.md
  71. +120 −81 docs/schematypes.md
  72. +3 −3 docs/search.pug
  73. +107 −40 docs/source/api.js
  74. +5 −5 docs/source/home.js
  75. +75 −42 docs/source/index.js
  76. +8 −0 docs/source/tutorials.js
  77. +7 −0 docs/source/typescript.js
  78. +29 −0 docs/source/utils.js
  79. +0 −28 docs/splitApiDocs.js
  80. +3 −3 docs/sponsors.pug
  81. +25 −28 docs/subdocs.md
  82. +9 −9 docs/timestamps.md
  83. +27 −14 docs/transactions.md
  84. +5 −4 docs/tutorials/custom-casting.md
  85. +8 −8 docs/tutorials/dates.md
  86. +10 −10 docs/tutorials/findoneandupdate.md
  87. +39 −17 docs/tutorials/getters-setters.md
  88. +0 −15 docs/tutorials/index.js
  89. +15 −15 docs/tutorials/lean.md
  90. +14 −15 docs/tutorials/query_casting.md
  91. +11 −12 docs/tutorials/ssl.md
  92. +19 −19 docs/tutorials/virtuals.md
  93. +12 −12 docs/typescript.md
  94. +0 −14 docs/typescript/index.js
  95. +6 −6 docs/typescript/query-helpers.md
  96. +24 −15 docs/typescript/schemas.md
  97. +7 −6 docs/typescript/statics-and-methods.md
  98. +3 −3 docs/typescript/statics.md
  99. +50 −9 docs/typescript/virtuals.md
  100. +51 −51 docs/validation.md
  101. +27 −0 docs/version-support.md
  102. +2 −2 examples/aggregate/aggregate.js
  103. +2 −2 examples/doc-methods.js
  104. +1 −1 examples/express/connection-sharing/README.md
  105. +2 −2 examples/express/connection-sharing/app.js
  106. +1 −1 examples/geospatial/geoJSONexample.js
  107. +2 −2 examples/geospatial/geospatial.js
  108. +1 −1 examples/globalschemas/gs_example.js
  109. +1 −1 examples/lean/lean.js
  110. +2 −2 examples/mapreduce/mapreduce.js
  111. +1 −1 examples/population/population-across-three-collections.js
  112. +2 −2 examples/population/population-basic.js
  113. +2 −2 examples/population/population-of-existing-doc.js
  114. +2 −2 examples/population/population-of-multiple-existing-docs.js
  115. +2 −2 examples/population/population-options.js
  116. +2 −2 examples/population/population-plain-objects.js
  117. +1 −1 examples/promises/promise.js
  118. +2 −2 examples/querybuilder/querybuilder.js
  119. +1 −1 examples/redis-todo/db/index.js
  120. +1 −1 examples/replicasets/replica-sets.js
  121. +1 −1 examples/statics/statics.js
  122. +3 −4 index.pug
  123. +43 −44 lib/aggregate.js
  124. +1 −1 lib/browser.js
  125. +15 −2 lib/cast.js
  126. +30 −19 lib/connection.js
  127. +3 −3 lib/cursor/AggregationCursor.js
  128. +16 −1 lib/cursor/ChangeStream.js
  129. +22 −3 lib/cursor/QueryCursor.js
  130. +240 −101 lib/document.js
  131. +54 −13 lib/drivers/node-mongodb-native/collection.js
  132. +21 −10 lib/error/index.js
  133. +1 −1 lib/error/objectParameter.js
  134. +1 −1 lib/error/serverSelection.js
  135. +5 −4 lib/error/validator.js
  136. +30 −9 lib/helpers/common.js
  137. +79 −65 lib/helpers/cursor/eachAsync.js
  138. +2 −1 lib/helpers/discriminator/mergeDiscriminatorSchema.js
  139. +17 −4 lib/helpers/document/applyDefaults.js
  140. +11 −1 lib/helpers/document/compile.js
  141. +6 −2 lib/helpers/model/discriminator.js
  142. +0 −39 lib/helpers/path/flattenObjectWithDottedPaths.js
  143. +16 −3 lib/helpers/populate/assignRawDocsToIdStructure.js
  144. +7 −0 lib/helpers/populate/assignVals.js
  145. +11 −0 lib/helpers/populate/createPopulateQueryFilter.js
  146. +7 −5 lib/helpers/populate/getModelsMapForPopulate.js
  147. +2 −0 lib/helpers/populate/getSchemaTypes.js
  148. +15 −11 lib/helpers/printJestWarning.js
  149. +11 −0 lib/helpers/printStrictQueryWarning.js
  150. +4 −3 lib/helpers/processConnectionOptions.js
  151. +1 −0 lib/helpers/projection/hasIncludedChildren.js
  152. +8 −0 lib/helpers/projection/isNestedProjection.js
  153. +1 −1 lib/helpers/query/cast$expr.js
  154. +1 −0 lib/helpers/query/castUpdate.js
  155. +12 −0 lib/helpers/schema/applyBuiltinPlugins.js
  156. +0 −1 lib/helpers/schema/getPath.js
  157. +1 −0 lib/helpers/schema/merge.js
  158. +1 −1 lib/helpers/timestamps/setupTimestamps.js
  159. +41 −15 lib/helpers/update/castArrayFilters.js
  160. +78 −58 lib/index.js
  161. +309 −150 lib/model.js
  162. +0 −28 lib/plugins/clearValidating.js
  163. +7 −0 lib/plugins/index.js
  164. +241 −211 lib/query.js
  165. +8 −1 lib/queryhelpers.js
  166. +121 −13 lib/schema.js
  167. +100 −0 lib/schema/DocumentArrayElement.js
  168. +7 −5 lib/schema/SubdocumentPath.js
  169. +8 −8 lib/schema/array.js
  170. +13 −32 lib/schema/documentarray.js
  171. +1 −1 lib/schema/operators/text.js
  172. +3 −3 lib/schema/string.js
  173. +17 −12 lib/schema/uuid.js
  174. +18 −15 lib/schematype.js
  175. +1 −1 lib/types/ArraySubdocument.js
  176. +1 −1 lib/types/array/index.js
  177. +13 −14 lib/types/array/methods/index.js
  178. +1 −1 lib/types/buffer.js
  179. +48 −15 lib/types/map.js
  180. +3 −3 lib/types/subdocument.js
  181. +2 −0 lib/utils.js
  182. +1 −1 lib/virtualtype.js
  183. +47 −33 package.json
  184. +49 −26 docs/search.js → scripts/generateSearch.js
  185. +11 −2 scripts/static.js
  186. +15 −0 scripts/tsc-diagnostics-check.js
  187. +230 −35 scripts/website.js
  188. +3 −0 test/.eslintrc.yml
  189. +1 −0 test/aggregate.test.js
  190. +9 −6 test/collection.capped.test.js
  191. +26 −3 test/collection.test.js
  192. +119 −33 test/connection.test.js
  193. +40 −0 test/deno.js
  194. +54 −0 test/deno_mocha.js
  195. +5 −5 test/docs/asyncIterator.test.js
  196. +5 −1 test/docs/cast.test.js
  197. +5 −4 test/docs/date.test.js
  198. +43 −1 test/docs/debug.test.js
  199. +2 −2 test/docs/defaults.test.js
  200. +39 −3 test/docs/discriminators.test.js
  201. +10 −6 test/docs/findoneandupdate.test.js
  202. +58 −2 test/docs/getters-setters.test.js
  203. +11 −2 test/docs/lean.test.js
  204. +24 −24 test/docs/promises.test.js
  205. +2 −2 test/docs/schemas.test.js
  206. +22 −23 test/docs/transactions.test.js
  207. +24 −23 test/docs/validation.test.js
  208. +8 −5 test/docs/virtuals.test.js
  209. +53 −0 test/document.modified.test.js
  210. +630 −8 test/document.test.js
  211. +7 −0 test/errors.validation.test.js
  212. +2 −0 test/helpers/clone.test.js
  213. +24 −0 test/helpers/common.test.js
  214. +24 −0 test/helpers/cursor.eachAsync.test.js
  215. +4 −1 test/helpers/indexes.getRelatedIndexes.test.js
  216. +2 −0 test/helpers/indexes.isIndexEqual.test.js
  217. +2 −0 test/helpers/isMongooseObject.test.js
  218. +2 −0 test/helpers/isSimpleValidator.test.js
  219. +17 −2 test/helpers/populate.getSchemaTypes.test.js
  220. +3 −1 test/helpers/populate.getVirtual.test.js
  221. +3 −1 test/helpers/projection.applyProjection.test.js
  222. +49 −0 test/helpers/update.castArrayFilters.test.js
  223. +44 −0 test/index.test.js
  224. +6 −0 test/mocha-fixtures.js
  225. +21 −0 test/model.discriminator.querying.test.js
  226. +131 −0 test/model.discriminator.test.js
  227. +17 −6 test/model.field.selection.test.js
  228. +0 −1 test/model.findOneAndReplace.test.js
  229. +10 −5 test/model.findOneAndUpdate.test.js
  230. +66 −0 test/model.indexes.test.js
  231. +424 −106 test/model.populate.test.js
  232. +295 −217 test/model.test.js
  233. +31 −2 test/model.update.test.js
  234. +147 −0 test/model.validate.test.js
  235. +79 −0 test/model.watch.test.js
  236. +27 −2 test/query.cursor.test.js
  237. +0 −2 test/query.middleware.test.js
  238. +186 −4 test/query.test.js
  239. +9 −0 test/schema.documentarray.test.js
  240. +1 −2 test/schema.subdocumentpath.test.js
  241. +188 −10 test/schema.test.js
  242. +50 −2 test/schema.uuid.test.js
  243. +96 −5 test/schema.validation.test.js
  244. +2 −0 test/schematype.test.js
  245. +1 −1 test/shard.test.js
  246. +2 −0 test/types.array.test.js
  247. +18 −0 test/types.documentarray.test.js
  248. +53 −0 test/types.map.test.js
  249. +8 −15 test/types.subdocument.test.js
  250. +2 −0 test/types/.eslintrc.yml
  251. +5 −5 test/types/PipelineStage.test.ts
  252. +6 −1 test/types/aggregate.test.ts
  253. +1 −1 test/types/base.test.ts
  254. +6 −6 test/types/connect.test.ts
  255. +12 −12 test/types/connection.test.ts
  256. +1 −1 test/types/discriminator.test.ts
  257. +7 −0 test/types/expressions.test.ts
  258. +12 −2 test/types/lean.test.ts
  259. +46 −6 test/types/middleware.test.ts
  260. +73 −3 test/types/models.test.ts
  261. +17 −0 test/types/mongo.test.ts
  262. +30 −0 test/types/populate.test.ts
  263. +9 −0 test/types/queries.test.ts
  264. +8 −0 test/types/querycursor.test.ts
  265. +265 −5 test/types/schema.test.ts
  266. +19 −0 test/types/schemaTypeOptions.test.ts
  267. +32 −0 test/types/subdocuments.test.ts
  268. +4 −1 test/types/virtuals.test.ts
  269. +2 −2 test/virtualtype.test.js
  270. +2 −2 tools/auth.js
  271. +4 −4 tools/sharded.js
  272. +13 −71 types/aggregate.d.ts
  273. +9 −0 types/augmentations.d.ts
  274. +0 −2 types/collection.d.ts
  275. +4 −4 types/connection.d.ts
  276. +11 −4 types/cursor.d.ts
  277. +5 −5 types/document.d.ts
  278. +5 −0 types/error.d.ts
  279. +154 −153 types/expressions.d.ts
  280. +53 −26 types/index.d.ts
  281. +113 −66 types/inferschematype.d.ts
  282. +19 −1 types/middlewares.d.ts
  283. +54 −17 types/models.d.ts
  284. +8 −1 types/mongooseoptions.d.ts
  285. +40 −36 types/pipelinestage.d.ts
  286. +36 −31 types/populate.d.ts
  287. +13 −13 types/query.d.ts
  288. +16 −2 types/schemaoptions.d.ts
  289. +60 −9 types/schematypes.d.ts
  290. +4 −4 types/session.d.ts
  291. +2 −2 types/types.d.ts
  292. +2 −0 types/utility.d.ts
  293. +4 −2 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