create-mern-omar 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/index.js +26 -22
- package/package.json +3 -11
- package/templates/.env.example +2 -0
- package/templates/.gitignore.template +2 -0
- package/templates/controllers/users.routes.js +10 -0
- package/templates/models/User.js +26 -0
- package/{test-proj/package-lock.json → templates/node_modules/.package-lock.json} +0 -11
- package/templates/node_modules/@mongodb-js/saslprep/LICENSE +22 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/.esm-wrapper.mjs +4 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/browser.d.ts +5 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/browser.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/browser.js +12 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/browser.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts +3 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js +5 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts +3 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data.js +5 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-data.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts +7 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-src.js +881 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/code-points-src.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts +2 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js +83 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/index.d.ts +11 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/index.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/index.js +65 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/index.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts +10 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js +32 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/node.d.ts +10 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/node.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/node.js +15 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/node.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/util.d.ts +2 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/util.d.ts.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/util.js +11 -0
- package/templates/node_modules/@mongodb-js/saslprep/dist/util.js.map +1 -0
- package/templates/node_modules/@mongodb-js/saslprep/package.json +87 -0
- package/templates/node_modules/@mongodb-js/saslprep/readme.md +29 -0
- package/templates/node_modules/@types/webidl-conversions/LICENSE +21 -0
- package/templates/node_modules/@types/webidl-conversions/README.md +15 -0
- package/templates/node_modules/@types/webidl-conversions/index.d.ts +91 -0
- package/templates/node_modules/@types/webidl-conversions/package.json +30 -0
- package/templates/node_modules/@types/whatwg-url/LICENSE +21 -0
- package/templates/node_modules/@types/whatwg-url/README.md +15 -0
- package/templates/node_modules/@types/whatwg-url/index.d.ts +172 -0
- package/templates/node_modules/@types/whatwg-url/lib/URL-impl.d.ts +22 -0
- package/templates/node_modules/@types/whatwg-url/lib/URL.d.ts +66 -0
- package/templates/node_modules/@types/whatwg-url/lib/URLSearchParams-impl.d.ts +20 -0
- package/templates/node_modules/@types/whatwg-url/lib/URLSearchParams.d.ts +92 -0
- package/templates/node_modules/@types/whatwg-url/package.json +38 -0
- package/templates/node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts +4 -0
- package/templates/node_modules/accepts/HISTORY.md +250 -0
- package/templates/node_modules/accepts/LICENSE +23 -0
- package/templates/node_modules/accepts/README.md +140 -0
- package/templates/node_modules/accepts/index.js +238 -0
- package/templates/node_modules/accepts/package.json +47 -0
- package/templates/node_modules/basic-auth/HISTORY.md +52 -0
- package/templates/node_modules/basic-auth/LICENSE +24 -0
- package/templates/node_modules/basic-auth/README.md +113 -0
- package/templates/node_modules/basic-auth/index.js +133 -0
- package/templates/node_modules/basic-auth/package.json +41 -0
- package/templates/node_modules/body-parser/LICENSE +23 -0
- package/templates/node_modules/body-parser/README.md +494 -0
- package/templates/node_modules/body-parser/index.js +80 -0
- package/templates/node_modules/body-parser/lib/read.js +250 -0
- package/templates/node_modules/body-parser/lib/types/json.js +166 -0
- package/templates/node_modules/body-parser/lib/types/raw.js +43 -0
- package/templates/node_modules/body-parser/lib/types/text.js +37 -0
- package/templates/node_modules/body-parser/lib/types/urlencoded.js +142 -0
- package/templates/node_modules/body-parser/lib/utils.js +96 -0
- package/templates/node_modules/body-parser/package.json +52 -0
- package/templates/node_modules/bson/LICENSE.md +201 -0
- package/templates/node_modules/bson/README.md +291 -0
- package/templates/node_modules/bson/bson.d.ts +1729 -0
- package/templates/node_modules/bson/etc/prepare.js +19 -0
- package/templates/node_modules/bson/lib/bson.bundle.js +4675 -0
- package/templates/node_modules/bson/lib/bson.bundle.js.map +1 -0
- package/templates/node_modules/bson/lib/bson.cjs +4670 -0
- package/templates/node_modules/bson/lib/bson.cjs.map +1 -0
- package/templates/node_modules/bson/lib/bson.mjs +4639 -0
- package/templates/node_modules/bson/lib/bson.mjs.map +1 -0
- package/templates/node_modules/bson/lib/bson.node.mjs +4639 -0
- package/templates/node_modules/bson/lib/bson.node.mjs.map +1 -0
- package/templates/node_modules/bson/lib/bson.rn.cjs +4680 -0
- package/templates/node_modules/bson/lib/bson.rn.cjs.map +1 -0
- package/templates/node_modules/bson/package.json +118 -0
- package/templates/node_modules/bson/src/binary.ts +751 -0
- package/templates/node_modules/bson/src/bson.ts +248 -0
- package/templates/node_modules/bson/src/bson_value.ts +55 -0
- package/templates/node_modules/bson/src/code.ts +69 -0
- package/templates/node_modules/bson/src/constants.ts +147 -0
- package/templates/node_modules/bson/src/db_ref.ts +128 -0
- package/templates/node_modules/bson/src/decimal128.ts +855 -0
- package/templates/node_modules/bson/src/double.ts +115 -0
- package/templates/node_modules/bson/src/error.ts +105 -0
- package/templates/node_modules/bson/src/extended_json.ts +513 -0
- package/templates/node_modules/bson/src/index.ts +19 -0
- package/templates/node_modules/bson/src/int_32.ts +101 -0
- package/templates/node_modules/bson/src/long.ts +1240 -0
- package/templates/node_modules/bson/src/max_key.ts +31 -0
- package/templates/node_modules/bson/src/min_key.ts +31 -0
- package/templates/node_modules/bson/src/objectid.ts +382 -0
- package/templates/node_modules/bson/src/parse_utf8.ts +35 -0
- package/templates/node_modules/bson/src/parser/calculate_size.ts +218 -0
- package/templates/node_modules/bson/src/parser/deserializer.ts +627 -0
- package/templates/node_modules/bson/src/parser/on_demand/index.ts +32 -0
- package/templates/node_modules/bson/src/parser/on_demand/parse_to_elements.ts +190 -0
- package/templates/node_modules/bson/src/parser/serializer.ts +954 -0
- package/templates/node_modules/bson/src/parser/utils.ts +69 -0
- package/templates/node_modules/bson/src/regexp.ts +114 -0
- package/templates/node_modules/bson/src/symbol.ts +55 -0
- package/templates/node_modules/bson/src/timestamp.ts +176 -0
- package/templates/node_modules/bson/src/utils/byte_utils.ts +63 -0
- package/templates/node_modules/bson/src/utils/latin.ts +104 -0
- package/templates/node_modules/bson/src/utils/node_byte_utils.ts +161 -0
- package/templates/node_modules/bson/src/utils/number_utils.ts +204 -0
- package/templates/node_modules/bson/src/utils/string_utils.ts +44 -0
- package/templates/node_modules/bson/src/utils/web_byte_utils.ts +216 -0
- package/templates/node_modules/bytes/History.md +97 -0
- package/templates/node_modules/bytes/LICENSE +23 -0
- package/templates/node_modules/bytes/Readme.md +152 -0
- package/templates/node_modules/bytes/index.js +170 -0
- package/templates/node_modules/bytes/package.json +42 -0
- package/templates/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
- package/templates/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/templates/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/templates/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
- package/templates/node_modules/call-bind-apply-helpers/LICENSE +21 -0
- package/templates/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/templates/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/templates/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/templates/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/templates/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/templates/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/templates/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/templates/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/templates/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/templates/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
- package/templates/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/templates/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/templates/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/templates/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/templates/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/templates/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/templates/node_modules/call-bound/.eslintrc +13 -0
- package/templates/node_modules/call-bound/.github/FUNDING.yml +12 -0
- package/templates/node_modules/call-bound/.nycrc +9 -0
- package/templates/node_modules/call-bound/CHANGELOG.md +42 -0
- package/templates/node_modules/call-bound/LICENSE +21 -0
- package/templates/node_modules/call-bound/README.md +53 -0
- package/templates/node_modules/call-bound/index.d.ts +94 -0
- package/templates/node_modules/call-bound/index.js +19 -0
- package/templates/node_modules/call-bound/package.json +99 -0
- package/templates/node_modules/call-bound/test/index.js +61 -0
- package/templates/node_modules/call-bound/tsconfig.json +10 -0
- package/templates/node_modules/content-disposition/HISTORY.md +72 -0
- package/templates/node_modules/content-disposition/LICENSE +22 -0
- package/templates/node_modules/content-disposition/README.md +142 -0
- package/templates/node_modules/content-disposition/index.js +458 -0
- package/templates/node_modules/content-disposition/package.json +43 -0
- package/templates/node_modules/content-type/HISTORY.md +29 -0
- package/templates/node_modules/content-type/LICENSE +22 -0
- package/templates/node_modules/content-type/README.md +94 -0
- package/templates/node_modules/content-type/index.js +225 -0
- package/templates/node_modules/content-type/package.json +42 -0
- package/templates/node_modules/cookie/LICENSE +24 -0
- package/templates/node_modules/cookie/README.md +317 -0
- package/templates/node_modules/cookie/SECURITY.md +25 -0
- package/templates/node_modules/cookie/index.js +335 -0
- package/templates/node_modules/cookie/package.json +44 -0
- package/templates/node_modules/cookie-signature/History.md +70 -0
- package/templates/node_modules/cookie-signature/LICENSE +22 -0
- package/templates/node_modules/cookie-signature/Readme.md +23 -0
- package/templates/node_modules/cookie-signature/index.js +47 -0
- package/templates/node_modules/cookie-signature/package.json +24 -0
- package/templates/node_modules/debug/LICENSE +20 -0
- package/templates/node_modules/debug/README.md +481 -0
- package/templates/node_modules/debug/package.json +64 -0
- package/templates/node_modules/debug/src/browser.js +272 -0
- package/templates/node_modules/debug/src/common.js +292 -0
- package/templates/node_modules/debug/src/index.js +10 -0
- package/templates/node_modules/debug/src/node.js +263 -0
- package/templates/node_modules/depd/History.md +103 -0
- package/templates/node_modules/depd/LICENSE +22 -0
- package/templates/node_modules/depd/Readme.md +280 -0
- package/templates/node_modules/depd/index.js +538 -0
- package/templates/node_modules/depd/lib/browser/index.js +77 -0
- package/templates/node_modules/depd/package.json +45 -0
- package/templates/node_modules/dotenv/CHANGELOG.md +598 -0
- package/templates/node_modules/dotenv/LICENSE +23 -0
- package/templates/node_modules/dotenv/README-es.md +405 -0
- package/templates/node_modules/dotenv/README.md +692 -0
- package/templates/node_modules/dotenv/SECURITY.md +1 -0
- package/templates/node_modules/dotenv/config.d.ts +1 -0
- package/templates/node_modules/dotenv/config.js +9 -0
- package/templates/node_modules/dotenv/lib/cli-options.js +17 -0
- package/templates/node_modules/dotenv/lib/env-options.js +28 -0
- package/templates/node_modules/dotenv/lib/main.d.ts +179 -0
- package/templates/node_modules/dotenv/lib/main.js +434 -0
- package/templates/node_modules/dotenv/package.json +62 -0
- package/templates/node_modules/dunder-proto/.eslintrc +5 -0
- package/templates/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
- package/templates/node_modules/dunder-proto/.nycrc +13 -0
- package/templates/node_modules/dunder-proto/CHANGELOG.md +24 -0
- package/templates/node_modules/dunder-proto/LICENSE +21 -0
- package/templates/node_modules/dunder-proto/README.md +54 -0
- package/templates/node_modules/dunder-proto/get.d.ts +5 -0
- package/templates/node_modules/dunder-proto/get.js +30 -0
- package/templates/node_modules/dunder-proto/package.json +76 -0
- package/templates/node_modules/dunder-proto/set.d.ts +5 -0
- package/templates/node_modules/dunder-proto/set.js +35 -0
- package/templates/node_modules/dunder-proto/test/get.js +34 -0
- package/templates/node_modules/dunder-proto/test/index.js +4 -0
- package/templates/node_modules/dunder-proto/test/set.js +50 -0
- package/templates/node_modules/dunder-proto/tsconfig.json +9 -0
- package/templates/node_modules/ee-first/LICENSE +22 -0
- package/templates/node_modules/ee-first/README.md +80 -0
- package/templates/node_modules/ee-first/index.js +95 -0
- package/templates/node_modules/ee-first/package.json +29 -0
- package/templates/node_modules/encodeurl/LICENSE +22 -0
- package/templates/node_modules/encodeurl/README.md +109 -0
- package/templates/node_modules/encodeurl/index.js +60 -0
- package/templates/node_modules/encodeurl/package.json +40 -0
- package/templates/node_modules/es-define-property/.eslintrc +13 -0
- package/templates/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/templates/node_modules/es-define-property/.nycrc +9 -0
- package/templates/node_modules/es-define-property/CHANGELOG.md +29 -0
- package/templates/node_modules/es-define-property/LICENSE +21 -0
- package/templates/node_modules/es-define-property/README.md +49 -0
- package/templates/node_modules/es-define-property/index.d.ts +3 -0
- package/templates/node_modules/es-define-property/index.js +14 -0
- package/templates/node_modules/es-define-property/package.json +81 -0
- package/templates/node_modules/es-define-property/test/index.js +56 -0
- package/templates/node_modules/es-define-property/tsconfig.json +10 -0
- package/templates/node_modules/es-errors/.eslintrc +5 -0
- package/templates/node_modules/es-errors/.github/FUNDING.yml +12 -0
- package/templates/node_modules/es-errors/CHANGELOG.md +40 -0
- package/templates/node_modules/es-errors/LICENSE +21 -0
- package/templates/node_modules/es-errors/README.md +55 -0
- package/templates/node_modules/es-errors/eval.d.ts +3 -0
- package/templates/node_modules/es-errors/eval.js +4 -0
- package/templates/node_modules/es-errors/index.d.ts +3 -0
- package/templates/node_modules/es-errors/index.js +4 -0
- package/templates/node_modules/es-errors/package.json +80 -0
- package/templates/node_modules/es-errors/range.d.ts +3 -0
- package/templates/node_modules/es-errors/range.js +4 -0
- package/templates/node_modules/es-errors/ref.d.ts +3 -0
- package/templates/node_modules/es-errors/ref.js +4 -0
- package/templates/node_modules/es-errors/syntax.d.ts +3 -0
- package/templates/node_modules/es-errors/syntax.js +4 -0
- package/templates/node_modules/es-errors/test/index.js +19 -0
- package/templates/node_modules/es-errors/tsconfig.json +49 -0
- package/templates/node_modules/es-errors/type.d.ts +3 -0
- package/templates/node_modules/es-errors/type.js +4 -0
- package/templates/node_modules/es-errors/uri.d.ts +3 -0
- package/templates/node_modules/es-errors/uri.js +4 -0
- package/templates/node_modules/es-object-atoms/.eslintrc +16 -0
- package/templates/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/templates/node_modules/es-object-atoms/CHANGELOG.md +37 -0
- package/templates/node_modules/es-object-atoms/LICENSE +21 -0
- package/templates/node_modules/es-object-atoms/README.md +63 -0
- package/templates/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/templates/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/templates/node_modules/es-object-atoms/ToObject.d.ts +7 -0
- package/templates/node_modules/es-object-atoms/ToObject.js +10 -0
- package/templates/node_modules/es-object-atoms/index.d.ts +3 -0
- package/templates/node_modules/es-object-atoms/index.js +4 -0
- package/templates/node_modules/es-object-atoms/isObject.d.ts +3 -0
- package/templates/node_modules/es-object-atoms/isObject.js +6 -0
- package/templates/node_modules/es-object-atoms/package.json +80 -0
- package/templates/node_modules/es-object-atoms/test/index.js +38 -0
- package/templates/node_modules/es-object-atoms/tsconfig.json +6 -0
- package/templates/node_modules/escape-html/LICENSE +24 -0
- package/templates/node_modules/escape-html/Readme.md +43 -0
- package/templates/node_modules/escape-html/index.js +78 -0
- package/templates/node_modules/escape-html/package.json +24 -0
- package/templates/node_modules/etag/HISTORY.md +83 -0
- package/templates/node_modules/etag/LICENSE +22 -0
- package/templates/node_modules/etag/README.md +159 -0
- package/templates/node_modules/etag/index.js +131 -0
- package/templates/node_modules/etag/package.json +47 -0
- package/templates/node_modules/express/LICENSE +24 -0
- package/templates/node_modules/express/Readme.md +276 -0
- package/templates/node_modules/express/index.js +11 -0
- package/templates/node_modules/express/lib/application.js +631 -0
- package/templates/node_modules/express/lib/express.js +81 -0
- package/templates/node_modules/express/lib/request.js +514 -0
- package/templates/node_modules/express/lib/response.js +1053 -0
- package/templates/node_modules/express/lib/utils.js +271 -0
- package/templates/node_modules/express/lib/view.js +205 -0
- package/templates/node_modules/express/package.json +99 -0
- package/templates/node_modules/finalhandler/HISTORY.md +239 -0
- package/templates/node_modules/finalhandler/LICENSE +22 -0
- package/templates/node_modules/finalhandler/README.md +150 -0
- package/templates/node_modules/finalhandler/index.js +293 -0
- package/templates/node_modules/finalhandler/package.json +47 -0
- package/templates/node_modules/forwarded/HISTORY.md +21 -0
- package/templates/node_modules/forwarded/LICENSE +22 -0
- package/templates/node_modules/forwarded/README.md +57 -0
- package/templates/node_modules/forwarded/index.js +90 -0
- package/templates/node_modules/forwarded/package.json +45 -0
- package/templates/node_modules/fresh/HISTORY.md +80 -0
- package/templates/node_modules/fresh/LICENSE +23 -0
- package/templates/node_modules/fresh/README.md +117 -0
- package/templates/node_modules/fresh/index.js +136 -0
- package/templates/node_modules/fresh/package.json +46 -0
- package/templates/node_modules/function-bind/.eslintrc +21 -0
- package/templates/node_modules/function-bind/.github/FUNDING.yml +12 -0
- package/templates/node_modules/function-bind/.github/SECURITY.md +3 -0
- package/templates/node_modules/function-bind/.nycrc +13 -0
- package/templates/node_modules/function-bind/CHANGELOG.md +136 -0
- package/templates/node_modules/function-bind/LICENSE +20 -0
- package/templates/node_modules/function-bind/README.md +46 -0
- package/templates/node_modules/function-bind/implementation.js +84 -0
- package/templates/node_modules/function-bind/index.js +5 -0
- package/templates/node_modules/function-bind/package.json +87 -0
- package/templates/node_modules/function-bind/test/.eslintrc +9 -0
- package/templates/node_modules/function-bind/test/index.js +252 -0
- package/templates/node_modules/get-intrinsic/.eslintrc +42 -0
- package/templates/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
- package/templates/node_modules/get-intrinsic/.nycrc +9 -0
- package/templates/node_modules/get-intrinsic/CHANGELOG.md +186 -0
- package/templates/node_modules/get-intrinsic/LICENSE +21 -0
- package/templates/node_modules/get-intrinsic/README.md +71 -0
- package/templates/node_modules/get-intrinsic/index.js +378 -0
- package/templates/node_modules/get-intrinsic/package.json +97 -0
- package/templates/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
- package/templates/node_modules/get-proto/.eslintrc +10 -0
- package/templates/node_modules/get-proto/.github/FUNDING.yml +12 -0
- package/templates/node_modules/get-proto/.nycrc +9 -0
- package/templates/node_modules/get-proto/CHANGELOG.md +21 -0
- package/templates/node_modules/get-proto/LICENSE +21 -0
- package/templates/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
- package/templates/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/templates/node_modules/get-proto/README.md +50 -0
- package/templates/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
- package/templates/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/templates/node_modules/get-proto/index.d.ts +5 -0
- package/templates/node_modules/get-proto/index.js +27 -0
- package/templates/node_modules/get-proto/package.json +81 -0
- package/templates/node_modules/get-proto/test/index.js +68 -0
- package/templates/node_modules/get-proto/tsconfig.json +9 -0
- package/templates/node_modules/gopd/.eslintrc +16 -0
- package/templates/node_modules/gopd/.github/FUNDING.yml +12 -0
- package/templates/node_modules/gopd/CHANGELOG.md +45 -0
- package/templates/node_modules/gopd/LICENSE +21 -0
- package/templates/node_modules/gopd/README.md +40 -0
- package/templates/node_modules/gopd/gOPD.d.ts +1 -0
- package/templates/node_modules/gopd/gOPD.js +4 -0
- package/templates/node_modules/gopd/index.d.ts +5 -0
- package/templates/node_modules/gopd/index.js +15 -0
- package/templates/node_modules/gopd/package.json +77 -0
- package/templates/node_modules/gopd/test/index.js +36 -0
- package/templates/node_modules/gopd/tsconfig.json +9 -0
- package/templates/node_modules/has-symbols/.eslintrc +11 -0
- package/templates/node_modules/has-symbols/.github/FUNDING.yml +12 -0
- package/templates/node_modules/has-symbols/.nycrc +9 -0
- package/templates/node_modules/has-symbols/CHANGELOG.md +91 -0
- package/templates/node_modules/has-symbols/LICENSE +21 -0
- package/templates/node_modules/has-symbols/README.md +46 -0
- package/templates/node_modules/has-symbols/index.d.ts +3 -0
- package/templates/node_modules/has-symbols/index.js +14 -0
- package/templates/node_modules/has-symbols/package.json +111 -0
- package/templates/node_modules/has-symbols/shams.d.ts +3 -0
- package/templates/node_modules/has-symbols/shams.js +45 -0
- package/templates/node_modules/has-symbols/test/index.js +22 -0
- package/templates/node_modules/has-symbols/test/shams/core-js.js +29 -0
- package/templates/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
- package/templates/node_modules/has-symbols/test/tests.js +58 -0
- package/templates/node_modules/has-symbols/tsconfig.json +10 -0
- package/templates/node_modules/hasown/.eslintrc +5 -0
- package/templates/node_modules/hasown/.github/FUNDING.yml +12 -0
- package/templates/node_modules/hasown/.nycrc +13 -0
- package/templates/node_modules/hasown/CHANGELOG.md +40 -0
- package/templates/node_modules/hasown/LICENSE +21 -0
- package/templates/node_modules/hasown/README.md +40 -0
- package/templates/node_modules/hasown/index.d.ts +3 -0
- package/templates/node_modules/hasown/index.js +8 -0
- package/templates/node_modules/hasown/package.json +92 -0
- package/templates/node_modules/hasown/tsconfig.json +6 -0
- package/templates/node_modules/http-errors/HISTORY.md +186 -0
- package/templates/node_modules/http-errors/LICENSE +23 -0
- package/templates/node_modules/http-errors/README.md +169 -0
- package/templates/node_modules/http-errors/index.js +290 -0
- package/templates/node_modules/http-errors/package.json +54 -0
- package/templates/node_modules/iconv-lite/Changelog.md +241 -0
- package/templates/node_modules/iconv-lite/LICENSE +21 -0
- package/templates/node_modules/iconv-lite/README.md +138 -0
- package/templates/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/templates/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/templates/node_modules/iconv-lite/encodings/index.js +23 -0
- package/templates/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/templates/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/templates/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/templates/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
- package/templates/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/templates/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/templates/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/templates/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/templates/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/templates/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/templates/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/templates/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/templates/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/templates/node_modules/iconv-lite/encodings/utf32.js +307 -0
- package/templates/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/templates/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/templates/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/templates/node_modules/iconv-lite/lib/index.d.ts +131 -0
- package/templates/node_modules/iconv-lite/lib/index.js +183 -0
- package/templates/node_modules/iconv-lite/lib/streams.js +105 -0
- package/templates/node_modules/iconv-lite/package.json +65 -0
- package/templates/node_modules/iconv-lite/types/encodings.d.ts +423 -0
- package/templates/node_modules/inherits/LICENSE +16 -0
- package/templates/node_modules/inherits/README.md +42 -0
- package/templates/node_modules/inherits/inherits.js +9 -0
- package/templates/node_modules/inherits/inherits_browser.js +27 -0
- package/templates/node_modules/inherits/package.json +29 -0
- package/templates/node_modules/ipaddr.js/LICENSE +19 -0
- package/templates/node_modules/ipaddr.js/README.md +233 -0
- package/templates/node_modules/ipaddr.js/ipaddr.min.js +1 -0
- package/templates/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
- package/templates/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
- package/templates/node_modules/ipaddr.js/package.json +35 -0
- package/templates/node_modules/is-promise/LICENSE +19 -0
- package/templates/node_modules/is-promise/index.d.ts +2 -0
- package/templates/node_modules/is-promise/index.js +6 -0
- package/templates/node_modules/is-promise/index.mjs +3 -0
- package/templates/node_modules/is-promise/package.json +30 -0
- package/templates/node_modules/is-promise/readme.md +33 -0
- package/templates/node_modules/kareem/.nyc_output/fa57d6c4-9e78-4624-9229-f77b87a07481.json +1 -0
- package/templates/node_modules/kareem/.nyc_output/processinfo/fa57d6c4-9e78-4624-9229-f77b87a07481.json +1 -0
- package/templates/node_modules/kareem/.nyc_output/processinfo/index.json +1 -0
- package/templates/node_modules/kareem/CHANGELOG.md +830 -0
- package/templates/node_modules/kareem/LICENSE +202 -0
- package/templates/node_modules/kareem/README.md +408 -0
- package/templates/node_modules/kareem/SECURITY.md +5 -0
- package/templates/node_modules/kareem/coverage/lcov-report/base.css +224 -0
- package/templates/node_modules/kareem/coverage/lcov-report/block-navigation.js +87 -0
- package/templates/node_modules/kareem/coverage/lcov-report/favicon.png +0 -0
- package/templates/node_modules/kareem/coverage/lcov-report/index.html +116 -0
- package/templates/node_modules/kareem/coverage/lcov-report/index.js.html +1603 -0
- package/templates/node_modules/kareem/coverage/lcov-report/prettify.css +1 -0
- package/templates/node_modules/kareem/coverage/lcov-report/prettify.js +2 -0
- package/templates/node_modules/kareem/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/templates/node_modules/kareem/coverage/lcov-report/sorter.js +196 -0
- package/templates/node_modules/kareem/coverage/lcov.info +423 -0
- package/templates/node_modules/kareem/index.d.ts +31 -0
- package/templates/node_modules/kareem/index.js +509 -0
- package/templates/node_modules/kareem/package.json +28 -0
- package/templates/node_modules/math-intrinsics/.eslintrc +16 -0
- package/templates/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/templates/node_modules/math-intrinsics/CHANGELOG.md +24 -0
- package/templates/node_modules/math-intrinsics/LICENSE +21 -0
- package/templates/node_modules/math-intrinsics/README.md +50 -0
- package/templates/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/templates/node_modules/math-intrinsics/abs.js +4 -0
- package/templates/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/templates/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/templates/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/templates/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/templates/node_modules/math-intrinsics/floor.js +4 -0
- package/templates/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/isFinite.js +12 -0
- package/templates/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/isInteger.js +16 -0
- package/templates/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/templates/node_modules/math-intrinsics/isNaN.js +6 -0
- package/templates/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/templates/node_modules/math-intrinsics/max.d.ts +1 -0
- package/templates/node_modules/math-intrinsics/max.js +4 -0
- package/templates/node_modules/math-intrinsics/min.d.ts +1 -0
- package/templates/node_modules/math-intrinsics/min.js +4 -0
- package/templates/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/mod.js +9 -0
- package/templates/node_modules/math-intrinsics/package.json +86 -0
- package/templates/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/templates/node_modules/math-intrinsics/pow.js +4 -0
- package/templates/node_modules/math-intrinsics/round.d.ts +1 -0
- package/templates/node_modules/math-intrinsics/round.js +4 -0
- package/templates/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/templates/node_modules/math-intrinsics/sign.js +11 -0
- package/templates/node_modules/math-intrinsics/test/index.js +192 -0
- package/templates/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/templates/node_modules/media-typer/HISTORY.md +50 -0
- package/templates/node_modules/media-typer/LICENSE +22 -0
- package/templates/node_modules/media-typer/README.md +93 -0
- package/templates/node_modules/media-typer/index.js +143 -0
- package/templates/node_modules/media-typer/package.json +33 -0
- package/templates/node_modules/memory-pager/.travis.yml +4 -0
- package/templates/node_modules/memory-pager/LICENSE +21 -0
- package/templates/node_modules/memory-pager/README.md +65 -0
- package/templates/node_modules/memory-pager/index.js +160 -0
- package/templates/node_modules/memory-pager/package.json +24 -0
- package/templates/node_modules/memory-pager/test.js +80 -0
- package/templates/node_modules/merge-descriptors/index.d.ts +11 -0
- package/templates/node_modules/merge-descriptors/index.js +26 -0
- package/templates/node_modules/merge-descriptors/license +11 -0
- package/templates/node_modules/merge-descriptors/package.json +50 -0
- package/templates/node_modules/merge-descriptors/readme.md +55 -0
- package/templates/node_modules/mime-db/HISTORY.md +541 -0
- package/templates/node_modules/mime-db/LICENSE +23 -0
- package/templates/node_modules/mime-db/README.md +109 -0
- package/templates/node_modules/mime-db/db.json +9342 -0
- package/templates/node_modules/mime-db/index.js +12 -0
- package/templates/node_modules/mime-db/package.json +56 -0
- package/templates/node_modules/mime-types/HISTORY.md +428 -0
- package/templates/node_modules/mime-types/LICENSE +23 -0
- package/templates/node_modules/mime-types/README.md +126 -0
- package/templates/node_modules/mime-types/index.js +211 -0
- package/templates/node_modules/mime-types/mimeScore.js +57 -0
- package/templates/node_modules/mime-types/package.json +49 -0
- package/templates/node_modules/mongodb/LICENSE.md +201 -0
- package/templates/node_modules/mongodb/README.md +355 -0
- package/templates/node_modules/mongodb/etc/prepare.js +12 -0
- package/templates/node_modules/mongodb/lib/admin.js +136 -0
- package/templates/node_modules/mongodb/lib/admin.js.map +1 -0
- package/templates/node_modules/mongodb/lib/bson.js +84 -0
- package/templates/node_modules/mongodb/lib/bson.js.map +1 -0
- package/templates/node_modules/mongodb/lib/bulk/common.js +835 -0
- package/templates/node_modules/mongodb/lib/bulk/common.js.map +1 -0
- package/templates/node_modules/mongodb/lib/bulk/ordered.js +67 -0
- package/templates/node_modules/mongodb/lib/bulk/ordered.js.map +1 -0
- package/templates/node_modules/mongodb/lib/bulk/unordered.js +92 -0
- package/templates/node_modules/mongodb/lib/bulk/unordered.js.map +1 -0
- package/templates/node_modules/mongodb/lib/change_stream.js +511 -0
- package/templates/node_modules/mongodb/lib/change_stream.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +272 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +609 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/client_encryption.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/errors.js +138 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/errors.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +85 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/aws.js +23 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/aws.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/azure.js +132 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/azure.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/gcp.js +16 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/gcp.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/index.js +43 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/providers/index.js.map +1 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/state_machine.js +426 -0
- package/templates/node_modules/mongodb/lib/client-side-encryption/state_machine.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/auth_provider.js +51 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/auth_provider.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +102 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/gssapi.js +154 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/gssapi.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +168 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +133 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js +84 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +62 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js +141 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js +44 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +39 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +122 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +31 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js +52 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +22 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +73 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/plain.js +26 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/plain.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/providers.js +22 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/providers.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/scram.js +254 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/scram.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/x509.js +36 -0
- package/templates/node_modules/mongodb/lib/cmap/auth/x509.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/command_monitoring_events.js +223 -0
- package/templates/node_modules/mongodb/lib/cmap/command_monitoring_events.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/commands.js +535 -0
- package/templates/node_modules/mongodb/lib/cmap/commands.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/connect.js +366 -0
- package/templates/node_modules/mongodb/lib/cmap/connect.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/connection.js +571 -0
- package/templates/node_modules/mongodb/lib/cmap/connection.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/connection_pool.js +558 -0
- package/templates/node_modules/mongodb/lib/cmap/connection_pool.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/connection_pool_events.js +190 -0
- package/templates/node_modules/mongodb/lib/cmap/connection_pool_events.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/errors.js +108 -0
- package/templates/node_modules/mongodb/lib/cmap/errors.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +241 -0
- package/templates/node_modules/mongodb/lib/cmap/handshake/client_metadata.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/metrics.js +62 -0
- package/templates/node_modules/mongodb/lib/cmap/metrics.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/stream_description.js +70 -0
- package/templates/node_modules/mongodb/lib/cmap/stream_description.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +163 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/compression.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +21 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/constants.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +111 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +222 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +315 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/responses.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/shared.js +35 -0
- package/templates/node_modules/mongodb/lib/cmap/wire_protocol/shared.js.map +1 -0
- package/templates/node_modules/mongodb/lib/collection.js +751 -0
- package/templates/node_modules/mongodb/lib/collection.js.map +1 -0
- package/templates/node_modules/mongodb/lib/connection_string.js +1089 -0
- package/templates/node_modules/mongodb/lib/connection_string.js.map +1 -0
- package/templates/node_modules/mongodb/lib/constants.js +170 -0
- package/templates/node_modules/mongodb/lib/constants.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/abstract_cursor.js +924 -0
- package/templates/node_modules/mongodb/lib/cursor/abstract_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/aggregation_cursor.js +164 -0
- package/templates/node_modules/mongodb/lib/cursor/aggregation_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/change_stream_cursor.js +104 -0
- package/templates/node_modules/mongodb/lib/cursor/change_stream_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/client_bulk_write_cursor.js +52 -0
- package/templates/node_modules/mongodb/lib/cursor/client_bulk_write_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/explainable_cursor.js +36 -0
- package/templates/node_modules/mongodb/lib/cursor/explainable_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/find_cursor.js +399 -0
- package/templates/node_modules/mongodb/lib/cursor/find_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/list_collections_cursor.js +34 -0
- package/templates/node_modules/mongodb/lib/cursor/list_collections_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/list_indexes_cursor.js +32 -0
- package/templates/node_modules/mongodb/lib/cursor/list_indexes_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js +14 -0
- package/templates/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/cursor/run_command_cursor.js +94 -0
- package/templates/node_modules/mongodb/lib/cursor/run_command_cursor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/db.js +420 -0
- package/templates/node_modules/mongodb/lib/db.js.map +1 -0
- package/templates/node_modules/mongodb/lib/deps.js +125 -0
- package/templates/node_modules/mongodb/lib/deps.js.map +1 -0
- package/templates/node_modules/mongodb/lib/encrypter.js +106 -0
- package/templates/node_modules/mongodb/lib/encrypter.js.map +1 -0
- package/templates/node_modules/mongodb/lib/error.js +1383 -0
- package/templates/node_modules/mongodb/lib/error.js.map +1 -0
- package/templates/node_modules/mongodb/lib/explain.js +59 -0
- package/templates/node_modules/mongodb/lib/explain.js.map +1 -0
- package/templates/node_modules/mongodb/lib/gridfs/download.js +305 -0
- package/templates/node_modules/mongodb/lib/gridfs/download.js.map +1 -0
- package/templates/node_modules/mongodb/lib/gridfs/index.js +164 -0
- package/templates/node_modules/mongodb/lib/gridfs/index.js.map +1 -0
- package/templates/node_modules/mongodb/lib/gridfs/upload.js +358 -0
- package/templates/node_modules/mongodb/lib/gridfs/upload.js.map +1 -0
- package/templates/node_modules/mongodb/lib/index.js +193 -0
- package/templates/node_modules/mongodb/lib/index.js.map +1 -0
- package/templates/node_modules/mongodb/lib/mongo_client.js +557 -0
- package/templates/node_modules/mongodb/lib/mongo_client.js.map +1 -0
- package/templates/node_modules/mongodb/lib/mongo_client_auth_providers.js +80 -0
- package/templates/node_modules/mongodb/lib/mongo_client_auth_providers.js.map +1 -0
- package/templates/node_modules/mongodb/lib/mongo_logger.js +649 -0
- package/templates/node_modules/mongodb/lib/mongo_logger.js.map +1 -0
- package/templates/node_modules/mongodb/lib/mongo_types.js +56 -0
- package/templates/node_modules/mongodb/lib/mongo_types.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/aggregate.js +90 -0
- package/templates/node_modules/mongodb/lib/operations/aggregate.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js +51 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js +340 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/common.js +3 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/common.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/executor.js +120 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/executor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js +204 -0
- package/templates/node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/command.js +83 -0
- package/templates/node_modules/mongodb/lib/operations/command.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/count.js +45 -0
- package/templates/node_modules/mongodb/lib/operations/count.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/create_collection.js +109 -0
- package/templates/node_modules/mongodb/lib/operations/create_collection.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/delete.js +125 -0
- package/templates/node_modules/mongodb/lib/operations/delete.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/distinct.js +61 -0
- package/templates/node_modules/mongodb/lib/operations/distinct.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/drop.js +93 -0
- package/templates/node_modules/mongodb/lib/operations/drop.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
- package/templates/node_modules/mongodb/lib/operations/end_sessions.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/estimated_document_count.js +41 -0
- package/templates/node_modules/mongodb/lib/operations/estimated_document_count.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/execute_operation.js +238 -0
- package/templates/node_modules/mongodb/lib/operations/execute_operation.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/find.js +148 -0
- package/templates/node_modules/mongodb/lib/operations/find.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/find_and_modify.js +158 -0
- package/templates/node_modules/mongodb/lib/operations/find_and_modify.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/get_more.js +62 -0
- package/templates/node_modules/mongodb/lib/operations/get_more.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/indexes.js +186 -0
- package/templates/node_modules/mongodb/lib/operations/indexes.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/insert.js +70 -0
- package/templates/node_modules/mongodb/lib/operations/insert.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/kill_cursors.js +43 -0
- package/templates/node_modules/mongodb/lib/operations/kill_cursors.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/list_collections.js +53 -0
- package/templates/node_modules/mongodb/lib/operations/list_collections.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/list_databases.js +40 -0
- package/templates/node_modules/mongodb/lib/operations/list_databases.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/operation.js +102 -0
- package/templates/node_modules/mongodb/lib/operations/operation.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/profiling_level.js +43 -0
- package/templates/node_modules/mongodb/lib/operations/profiling_level.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/remove_user.js +27 -0
- package/templates/node_modules/mongodb/lib/operations/remove_user.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/rename.js +38 -0
- package/templates/node_modules/mongodb/lib/operations/rename.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/run_command.js +47 -0
- package/templates/node_modules/mongodb/lib/operations/run_command.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/search_indexes/create.js +33 -0
- package/templates/node_modules/mongodb/lib/operations/search_indexes/create.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/search_indexes/drop.js +43 -0
- package/templates/node_modules/mongodb/lib/operations/search_indexes/drop.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/search_indexes/update.js +35 -0
- package/templates/node_modules/mongodb/lib/operations/search_indexes/update.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/set_profiling_level.js +53 -0
- package/templates/node_modules/mongodb/lib/operations/set_profiling_level.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/stats.js +27 -0
- package/templates/node_modules/mongodb/lib/operations/stats.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/update.js +188 -0
- package/templates/node_modules/mongodb/lib/operations/update.js.map +1 -0
- package/templates/node_modules/mongodb/lib/operations/validate_collection.js +37 -0
- package/templates/node_modules/mongodb/lib/operations/validate_collection.js.map +1 -0
- package/templates/node_modules/mongodb/lib/read_concern.js +73 -0
- package/templates/node_modules/mongodb/lib/read_concern.js.map +1 -0
- package/templates/node_modules/mongodb/lib/read_preference.js +191 -0
- package/templates/node_modules/mongodb/lib/read_preference.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/common.js +49 -0
- package/templates/node_modules/mongodb/lib/sdam/common.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/events.js +146 -0
- package/templates/node_modules/mongodb/lib/sdam/events.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/monitor.js +544 -0
- package/templates/node_modules/mongodb/lib/sdam/monitor.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/server.js +392 -0
- package/templates/node_modules/mongodb/lib/sdam/server.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/server_description.js +204 -0
- package/templates/node_modules/mongodb/lib/sdam/server_description.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/server_selection.js +231 -0
- package/templates/node_modules/mongodb/lib/sdam/server_selection.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/server_selection_events.js +85 -0
- package/templates/node_modules/mongodb/lib/sdam/server_selection_events.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/srv_polling.js +108 -0
- package/templates/node_modules/mongodb/lib/sdam/srv_polling.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/topology.js +650 -0
- package/templates/node_modules/mongodb/lib/sdam/topology.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sdam/topology_description.js +383 -0
- package/templates/node_modules/mongodb/lib/sdam/topology_description.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sessions.js +828 -0
- package/templates/node_modules/mongodb/lib/sessions.js.map +1 -0
- package/templates/node_modules/mongodb/lib/sort.js +103 -0
- package/templates/node_modules/mongodb/lib/sort.js.map +1 -0
- package/templates/node_modules/mongodb/lib/timeout.js +296 -0
- package/templates/node_modules/mongodb/lib/timeout.js.map +1 -0
- package/templates/node_modules/mongodb/lib/transactions.js +135 -0
- package/templates/node_modules/mongodb/lib/transactions.js.map +1 -0
- package/templates/node_modules/mongodb/lib/utils.js +1189 -0
- package/templates/node_modules/mongodb/lib/utils.js.map +1 -0
- package/templates/node_modules/mongodb/lib/write_concern.js +100 -0
- package/templates/node_modules/mongodb/lib/write_concern.js.map +1 -0
- package/templates/node_modules/mongodb/mongodb.d.ts +9010 -0
- package/templates/node_modules/mongodb/package.json +175 -0
- package/templates/node_modules/mongodb/src/admin.ts +173 -0
- package/templates/node_modules/mongodb/src/bson.ts +148 -0
- package/templates/node_modules/mongodb/src/bulk/common.ts +1251 -0
- package/templates/node_modules/mongodb/src/bulk/ordered.ts +83 -0
- package/templates/node_modules/mongodb/src/bulk/unordered.ts +115 -0
- package/templates/node_modules/mongodb/src/change_stream.ts +1158 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/auto_encrypter.ts +469 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/client_encryption.ts +1150 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/errors.ts +144 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/mongocryptd_manager.ts +100 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/providers/aws.ts +33 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/providers/azure.ts +181 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/providers/gcp.ts +16 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/providers/index.ts +207 -0
- package/templates/node_modules/mongodb/src/client-side-encryption/state_machine.ts +650 -0
- package/templates/node_modules/mongodb/src/cmap/auth/auth_provider.ts +77 -0
- package/templates/node_modules/mongodb/src/cmap/auth/aws_temporary_credentials.ts +127 -0
- package/templates/node_modules/mongodb/src/cmap/auth/gssapi.ts +202 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongo_credentials.ts +291 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_aws.ts +186 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/automated_callback_workflow.ts +88 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/azure_machine_workflow.ts +73 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/callback_workflow.ts +188 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/command_builders.ts +53 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/gcp_machine_workflow.ts +46 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/human_callback_workflow.ts +141 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts +30 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/token_cache.ts +62 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc/token_machine_workflow.ts +21 -0
- package/templates/node_modules/mongodb/src/cmap/auth/mongodb_oidc.ts +185 -0
- package/templates/node_modules/mongodb/src/cmap/auth/plain.ts +25 -0
- package/templates/node_modules/mongodb/src/cmap/auth/providers.ts +22 -0
- package/templates/node_modules/mongodb/src/cmap/auth/scram.ts +344 -0
- package/templates/node_modules/mongodb/src/cmap/auth/x509.ts +43 -0
- package/templates/node_modules/mongodb/src/cmap/command_monitoring_events.ts +316 -0
- package/templates/node_modules/mongodb/src/cmap/commands.ts +788 -0
- package/templates/node_modules/mongodb/src/cmap/connect.ts +499 -0
- package/templates/node_modules/mongodb/src/cmap/connection.ts +931 -0
- package/templates/node_modules/mongodb/src/cmap/connection_pool.ts +831 -0
- package/templates/node_modules/mongodb/src/cmap/connection_pool_events.ts +300 -0
- package/templates/node_modules/mongodb/src/cmap/errors.ts +119 -0
- package/templates/node_modules/mongodb/src/cmap/handshake/client_metadata.ts +352 -0
- package/templates/node_modules/mongodb/src/cmap/metrics.ts +58 -0
- package/templates/node_modules/mongodb/src/cmap/stream_description.ts +96 -0
- package/templates/node_modules/mongodb/src/cmap/wire_protocol/compression.ts +197 -0
- package/templates/node_modules/mongodb/src/cmap/wire_protocol/constants.ts +17 -0
- package/templates/node_modules/mongodb/src/cmap/wire_protocol/on_data.ts +139 -0
- package/templates/node_modules/mongodb/src/cmap/wire_protocol/on_demand/document.ts +358 -0
- package/templates/node_modules/mongodb/src/cmap/wire_protocol/responses.ts +393 -0
- package/templates/node_modules/mongodb/src/cmap/wire_protocol/shared.ts +48 -0
- package/templates/node_modules/mongodb/src/collection.ts +1314 -0
- package/templates/node_modules/mongodb/src/connection_string.ts +1296 -0
- package/templates/node_modules/mongodb/src/constants.ts +176 -0
- package/templates/node_modules/mongodb/src/cursor/abstract_cursor.ts +1247 -0
- package/templates/node_modules/mongodb/src/cursor/aggregation_cursor.ts +245 -0
- package/templates/node_modules/mongodb/src/cursor/change_stream_cursor.ts +171 -0
- package/templates/node_modules/mongodb/src/cursor/client_bulk_write_cursor.ts +83 -0
- package/templates/node_modules/mongodb/src/cursor/explainable_cursor.ts +51 -0
- package/templates/node_modules/mongodb/src/cursor/find_cursor.ts +497 -0
- package/templates/node_modules/mongodb/src/cursor/list_collections_cursor.ts +50 -0
- package/templates/node_modules/mongodb/src/cursor/list_indexes_cursor.ts +37 -0
- package/templates/node_modules/mongodb/src/cursor/list_search_indexes_cursor.ts +20 -0
- package/templates/node_modules/mongodb/src/cursor/run_command_cursor.ts +178 -0
- package/templates/node_modules/mongodb/src/db.ts +622 -0
- package/templates/node_modules/mongodb/src/deps.ts +287 -0
- package/templates/node_modules/mongodb/src/encrypter.ts +127 -0
- package/templates/node_modules/mongodb/src/error.ts +1571 -0
- package/templates/node_modules/mongodb/src/explain.ts +124 -0
- package/templates/node_modules/mongodb/src/gridfs/download.ts +483 -0
- package/templates/node_modules/mongodb/src/gridfs/index.ts +264 -0
- package/templates/node_modules/mongodb/src/gridfs/upload.ts +537 -0
- package/templates/node_modules/mongodb/src/index.ts +633 -0
- package/templates/node_modules/mongodb/src/mongo_client.ts +1155 -0
- package/templates/node_modules/mongodb/src/mongo_client_auth_providers.ts +87 -0
- package/templates/node_modules/mongodb/src/mongo_logger.ts +1076 -0
- package/templates/node_modules/mongodb/src/mongo_types.ts +678 -0
- package/templates/node_modules/mongodb/src/operations/aggregate.ts +153 -0
- package/templates/node_modules/mongodb/src/operations/client_bulk_write/client_bulk_write.ts +72 -0
- package/templates/node_modules/mongodb/src/operations/client_bulk_write/command_builder.ts +487 -0
- package/templates/node_modules/mongodb/src/operations/client_bulk_write/common.ts +276 -0
- package/templates/node_modules/mongodb/src/operations/client_bulk_write/executor.ts +149 -0
- package/templates/node_modules/mongodb/src/operations/client_bulk_write/results_merger.ts +260 -0
- package/templates/node_modules/mongodb/src/operations/command.ts +171 -0
- package/templates/node_modules/mongodb/src/operations/count.ts +74 -0
- package/templates/node_modules/mongodb/src/operations/create_collection.ts +218 -0
- package/templates/node_modules/mongodb/src/operations/delete.ts +183 -0
- package/templates/node_modules/mongodb/src/operations/distinct.ts +92 -0
- package/templates/node_modules/mongodb/src/operations/drop.ts +130 -0
- package/templates/node_modules/mongodb/src/operations/end_sessions.ts +44 -0
- package/templates/node_modules/mongodb/src/operations/estimated_document_count.ts +61 -0
- package/templates/node_modules/mongodb/src/operations/execute_operation.ts +318 -0
- package/templates/node_modules/mongodb/src/operations/find.ts +254 -0
- package/templates/node_modules/mongodb/src/operations/find_and_modify.ts +319 -0
- package/templates/node_modules/mongodb/src/operations/get_more.ts +108 -0
- package/templates/node_modules/mongodb/src/operations/indexes.ts +418 -0
- package/templates/node_modules/mongodb/src/operations/insert.ts +108 -0
- package/templates/node_modules/mongodb/src/operations/kill_cursors.ts +64 -0
- package/templates/node_modules/mongodb/src/operations/list_collections.ts +108 -0
- package/templates/node_modules/mongodb/src/operations/list_databases.ts +68 -0
- package/templates/node_modules/mongodb/src/operations/operation.ts +181 -0
- package/templates/node_modules/mongodb/src/operations/profiling_level.ts +46 -0
- package/templates/node_modules/mongodb/src/operations/remove_user.ts +36 -0
- package/templates/node_modules/mongodb/src/operations/rename.ts +55 -0
- package/templates/node_modules/mongodb/src/operations/run_command.ts +79 -0
- package/templates/node_modules/mongodb/src/operations/search_indexes/create.ts +56 -0
- package/templates/node_modules/mongodb/src/operations/search_indexes/drop.ts +58 -0
- package/templates/node_modules/mongodb/src/operations/search_indexes/update.ts +45 -0
- package/templates/node_modules/mongodb/src/operations/set_profiling_level.ts +74 -0
- package/templates/node_modules/mongodb/src/operations/stats.ts +37 -0
- package/templates/node_modules/mongodb/src/operations/update.ts +318 -0
- package/templates/node_modules/mongodb/src/operations/validate_collection.ts +50 -0
- package/templates/node_modules/mongodb/src/read_concern.ts +88 -0
- package/templates/node_modules/mongodb/src/read_preference.ts +256 -0
- package/templates/node_modules/mongodb/src/sdam/common.ts +74 -0
- package/templates/node_modules/mongodb/src/sdam/events.ts +219 -0
- package/templates/node_modules/mongodb/src/sdam/monitor.ts +771 -0
- package/templates/node_modules/mongodb/src/sdam/server.ts +577 -0
- package/templates/node_modules/mongodb/src/sdam/server_description.ts +291 -0
- package/templates/node_modules/mongodb/src/sdam/server_selection.ts +323 -0
- package/templates/node_modules/mongodb/src/sdam/server_selection_events.ts +142 -0
- package/templates/node_modules/mongodb/src/sdam/srv_polling.ts +146 -0
- package/templates/node_modules/mongodb/src/sdam/topology.ts +1096 -0
- package/templates/node_modules/mongodb/src/sdam/topology_description.ts +548 -0
- package/templates/node_modules/mongodb/src/sessions.ts +1160 -0
- package/templates/node_modules/mongodb/src/sort.ts +141 -0
- package/templates/node_modules/mongodb/src/timeout.ts +405 -0
- package/templates/node_modules/mongodb/src/transactions.ts +181 -0
- package/templates/node_modules/mongodb/src/utils.ts +1491 -0
- package/templates/node_modules/mongodb/src/write_concern.ts +183 -0
- package/templates/node_modules/mongodb/tsconfig.json +46 -0
- package/templates/node_modules/mongodb-connection-string-url/.esm-wrapper.mjs +6 -0
- package/templates/node_modules/mongodb-connection-string-url/LICENSE +192 -0
- package/templates/node_modules/mongodb-connection-string-url/README.md +25 -0
- package/templates/node_modules/mongodb-connection-string-url/lib/index.d.ts +63 -0
- package/templates/node_modules/mongodb-connection-string-url/lib/index.js +239 -0
- package/templates/node_modules/mongodb-connection-string-url/lib/index.js.map +1 -0
- package/templates/node_modules/mongodb-connection-string-url/lib/redact.d.ts +7 -0
- package/templates/node_modules/mongodb-connection-string-url/lib/redact.js +97 -0
- package/templates/node_modules/mongodb-connection-string-url/lib/redact.js.map +1 -0
- package/templates/node_modules/mongodb-connection-string-url/package.json +71 -0
- package/templates/node_modules/mongoose/LICENSE.md +22 -0
- package/templates/node_modules/mongoose/README.md +397 -0
- package/templates/node_modules/mongoose/SECURITY.md +1 -0
- package/templates/node_modules/mongoose/eslint.config.mjs +198 -0
- package/templates/node_modules/mongoose/index.js +64 -0
- package/templates/node_modules/mongoose/lib/aggregate.js +1189 -0
- package/templates/node_modules/mongoose/lib/cast/bigint.js +46 -0
- package/templates/node_modules/mongoose/lib/cast/boolean.js +32 -0
- package/templates/node_modules/mongoose/lib/cast/date.js +41 -0
- package/templates/node_modules/mongoose/lib/cast/decimal128.js +39 -0
- package/templates/node_modules/mongoose/lib/cast/double.js +50 -0
- package/templates/node_modules/mongoose/lib/cast/int32.js +36 -0
- package/templates/node_modules/mongoose/lib/cast/number.js +42 -0
- package/templates/node_modules/mongoose/lib/cast/objectid.js +29 -0
- package/templates/node_modules/mongoose/lib/cast/string.js +37 -0
- package/templates/node_modules/mongoose/lib/cast/uuid.js +35 -0
- package/templates/node_modules/mongoose/lib/cast.js +444 -0
- package/templates/node_modules/mongoose/lib/collection.js +321 -0
- package/templates/node_modules/mongoose/lib/connection.js +1849 -0
- package/templates/node_modules/mongoose/lib/connectionState.js +26 -0
- package/templates/node_modules/mongoose/lib/constants.js +73 -0
- package/templates/node_modules/mongoose/lib/cursor/aggregationCursor.js +466 -0
- package/templates/node_modules/mongoose/lib/cursor/changeStream.js +198 -0
- package/templates/node_modules/mongoose/lib/cursor/queryCursor.js +622 -0
- package/templates/node_modules/mongoose/lib/document.js +5481 -0
- package/templates/node_modules/mongoose/lib/driver.js +15 -0
- package/templates/node_modules/mongoose/lib/drivers/SPEC.md +4 -0
- package/templates/node_modules/mongoose/lib/drivers/node-mongodb-native/bulkWriteResult.js +5 -0
- package/templates/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +405 -0
- package/templates/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +521 -0
- package/templates/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js +10 -0
- package/templates/node_modules/mongoose/lib/error/browserMissingSchema.js +29 -0
- package/templates/node_modules/mongoose/lib/error/bulkSaveIncompleteError.js +44 -0
- package/templates/node_modules/mongoose/lib/error/bulkWriteError.js +41 -0
- package/templates/node_modules/mongoose/lib/error/cast.js +158 -0
- package/templates/node_modules/mongoose/lib/error/createCollectionsError.js +26 -0
- package/templates/node_modules/mongoose/lib/error/divergentArray.js +40 -0
- package/templates/node_modules/mongoose/lib/error/eachAsyncMultiError.js +41 -0
- package/templates/node_modules/mongoose/lib/error/index.js +237 -0
- package/templates/node_modules/mongoose/lib/error/invalidSchemaOption.js +32 -0
- package/templates/node_modules/mongoose/lib/error/messages.js +47 -0
- package/templates/node_modules/mongoose/lib/error/missingSchema.js +33 -0
- package/templates/node_modules/mongoose/lib/error/mongooseError.js +13 -0
- package/templates/node_modules/mongoose/lib/error/notFound.js +47 -0
- package/templates/node_modules/mongoose/lib/error/objectExpected.js +31 -0
- package/templates/node_modules/mongoose/lib/error/objectParameter.js +31 -0
- package/templates/node_modules/mongoose/lib/error/overwriteModel.js +31 -0
- package/templates/node_modules/mongoose/lib/error/parallelSave.js +33 -0
- package/templates/node_modules/mongoose/lib/error/parallelValidate.js +33 -0
- package/templates/node_modules/mongoose/lib/error/serverSelection.js +62 -0
- package/templates/node_modules/mongoose/lib/error/setOptionError.js +103 -0
- package/templates/node_modules/mongoose/lib/error/strict.js +35 -0
- package/templates/node_modules/mongoose/lib/error/strictPopulate.js +31 -0
- package/templates/node_modules/mongoose/lib/error/syncIndexes.js +30 -0
- package/templates/node_modules/mongoose/lib/error/validation.js +97 -0
- package/templates/node_modules/mongoose/lib/error/validator.js +100 -0
- package/templates/node_modules/mongoose/lib/error/version.js +38 -0
- package/templates/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +39 -0
- package/templates/node_modules/mongoose/lib/helpers/aggregate/stringifyFunctionOperators.js +50 -0
- package/templates/node_modules/mongoose/lib/helpers/arrayDepth.js +33 -0
- package/templates/node_modules/mongoose/lib/helpers/clone.js +204 -0
- package/templates/node_modules/mongoose/lib/helpers/common.js +127 -0
- package/templates/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +24 -0
- package/templates/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +225 -0
- package/templates/node_modules/mongoose/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +36 -0
- package/templates/node_modules/mongoose/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
- package/templates/node_modules/mongoose/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +12 -0
- package/templates/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +29 -0
- package/templates/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +28 -0
- package/templates/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +27 -0
- package/templates/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +91 -0
- package/templates/node_modules/mongoose/lib/helpers/document/applyDefaults.js +132 -0
- package/templates/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +105 -0
- package/templates/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +146 -0
- package/templates/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +45 -0
- package/templates/node_modules/mongoose/lib/helpers/document/compile.js +238 -0
- package/templates/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
- package/templates/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +53 -0
- package/templates/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js +35 -0
- package/templates/node_modules/mongoose/lib/helpers/each.js +25 -0
- package/templates/node_modules/mongoose/lib/helpers/error/combinePathErrors.js +22 -0
- package/templates/node_modules/mongoose/lib/helpers/firstKey.js +8 -0
- package/templates/node_modules/mongoose/lib/helpers/get.js +65 -0
- package/templates/node_modules/mongoose/lib/helpers/getConstructorName.js +16 -0
- package/templates/node_modules/mongoose/lib/helpers/getDefaultBulkwriteResult.js +18 -0
- package/templates/node_modules/mongoose/lib/helpers/getFunctionName.js +10 -0
- package/templates/node_modules/mongoose/lib/helpers/immediate.js +16 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/applySchemaCollation.js +13 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +63 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js +18 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +95 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +32 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/isTextIndex.js +16 -0
- package/templates/node_modules/mongoose/lib/helpers/indexes/isTimeseriesIndex.js +16 -0
- package/templates/node_modules/mongoose/lib/helpers/isAsyncFunction.js +9 -0
- package/templates/node_modules/mongoose/lib/helpers/isBsonType.js +15 -0
- package/templates/node_modules/mongoose/lib/helpers/isMongooseObject.js +22 -0
- package/templates/node_modules/mongoose/lib/helpers/isObject.js +16 -0
- package/templates/node_modules/mongoose/lib/helpers/isPOJO.js +12 -0
- package/templates/node_modules/mongoose/lib/helpers/isPromise.js +6 -0
- package/templates/node_modules/mongoose/lib/helpers/isSimpleValidator.js +22 -0
- package/templates/node_modules/mongoose/lib/helpers/minimize.js +41 -0
- package/templates/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +52 -0
- package/templates/node_modules/mongoose/lib/helpers/model/applyHooks.js +140 -0
- package/templates/node_modules/mongoose/lib/helpers/model/applyMethods.js +70 -0
- package/templates/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +33 -0
- package/templates/node_modules/mongoose/lib/helpers/model/applyStatics.js +13 -0
- package/templates/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +320 -0
- package/templates/node_modules/mongoose/lib/helpers/model/decorateBulkWriteResult.js +8 -0
- package/templates/node_modules/mongoose/lib/helpers/model/discriminator.js +265 -0
- package/templates/node_modules/mongoose/lib/helpers/model/pushNestedArrayPaths.js +15 -0
- package/templates/node_modules/mongoose/lib/helpers/omitUndefined.js +20 -0
- package/templates/node_modules/mongoose/lib/helpers/once.js +12 -0
- package/templates/node_modules/mongoose/lib/helpers/parallelLimit.js +37 -0
- package/templates/node_modules/mongoose/lib/helpers/path/parentPaths.js +18 -0
- package/templates/node_modules/mongoose/lib/helpers/path/setDottedPath.js +33 -0
- package/templates/node_modules/mongoose/lib/helpers/pluralize.js +95 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +129 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/assignVals.js +360 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +97 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +774 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +229 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/getVirtual.js +103 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/leanPopulateMap.js +7 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/lookupLocalFields.js +40 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +49 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +66 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/removeDeselectedForeignField.js +31 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +33 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/skipPopulateValue.js +10 -0
- package/templates/node_modules/mongoose/lib/helpers/populate/validateRef.js +19 -0
- package/templates/node_modules/mongoose/lib/helpers/printJestWarning.js +21 -0
- package/templates/node_modules/mongoose/lib/helpers/processConnectionOptions.js +65 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/applyProjection.js +83 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +41 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/isDefiningProjection.js +18 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/isExclusive.js +37 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/isInclusive.js +39 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/isNestedProjection.js +8 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +40 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/isPathSelectedInclusive.js +28 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/isSubpath.js +14 -0
- package/templates/node_modules/mongoose/lib/helpers/projection/parseProjection.js +33 -0
- package/templates/node_modules/mongoose/lib/helpers/query/applyGlobalOption.js +29 -0
- package/templates/node_modules/mongoose/lib/helpers/query/cast$expr.js +287 -0
- package/templates/node_modules/mongoose/lib/helpers/query/castFilterPath.js +54 -0
- package/templates/node_modules/mongoose/lib/helpers/query/castUpdate.js +643 -0
- package/templates/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +103 -0
- package/templates/node_modules/mongoose/lib/helpers/query/handleImmutable.js +44 -0
- package/templates/node_modules/mongoose/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
- package/templates/node_modules/mongoose/lib/helpers/query/hasDollarKeys.js +23 -0
- package/templates/node_modules/mongoose/lib/helpers/query/isOperator.js +14 -0
- package/templates/node_modules/mongoose/lib/helpers/query/sanitizeFilter.js +38 -0
- package/templates/node_modules/mongoose/lib/helpers/query/sanitizeProjection.js +14 -0
- package/templates/node_modules/mongoose/lib/helpers/query/selectPopulatedFields.js +62 -0
- package/templates/node_modules/mongoose/lib/helpers/query/trusted.js +13 -0
- package/templates/node_modules/mongoose/lib/helpers/query/validOps.js +3 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/addAutoId.js +7 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/applyBuiltinPlugins.js +12 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +55 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +20 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +37 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/cleanPositionalOperators.js +12 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/getIndexes.js +171 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/getKeysInSchemaOrder.js +28 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/getPath.js +43 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +20 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/handleTimestampOption.js +24 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/idGetter.js +34 -0
- package/templates/node_modules/mongoose/lib/helpers/schema/merge.js +36 -0
- package/templates/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +50 -0
- package/templates/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +161 -0
- package/templates/node_modules/mongoose/lib/helpers/specialProperties.js +3 -0
- package/templates/node_modules/mongoose/lib/helpers/symbols.js +20 -0
- package/templates/node_modules/mongoose/lib/helpers/timers.js +3 -0
- package/templates/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +26 -0
- package/templates/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +107 -0
- package/templates/node_modules/mongoose/lib/helpers/topology/allServersUnknown.js +12 -0
- package/templates/node_modules/mongoose/lib/helpers/topology/isAtlas.js +31 -0
- package/templates/node_modules/mongoose/lib/helpers/topology/isSSLError.js +16 -0
- package/templates/node_modules/mongoose/lib/helpers/update/applyTimestampsToChildren.js +193 -0
- package/templates/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +130 -0
- package/templates/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +113 -0
- package/templates/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +35 -0
- package/templates/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +33 -0
- package/templates/node_modules/mongoose/lib/helpers/update/moveImmutableProperties.js +53 -0
- package/templates/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +32 -0
- package/templates/node_modules/mongoose/lib/helpers/update/updatedPathsByArrayFilter.js +27 -0
- package/templates/node_modules/mongoose/lib/helpers/updateValidators.js +193 -0
- package/templates/node_modules/mongoose/lib/index.js +17 -0
- package/templates/node_modules/mongoose/lib/internal.js +46 -0
- package/templates/node_modules/mongoose/lib/model.js +5021 -0
- package/templates/node_modules/mongoose/lib/modifiedPathsSnapshot.js +9 -0
- package/templates/node_modules/mongoose/lib/mongoose.js +1411 -0
- package/templates/node_modules/mongoose/lib/options/populateOptions.js +36 -0
- package/templates/node_modules/mongoose/lib/options/propertyOptions.js +8 -0
- package/templates/node_modules/mongoose/lib/options/saveOptions.js +16 -0
- package/templates/node_modules/mongoose/lib/options/schemaArrayOptions.js +78 -0
- package/templates/node_modules/mongoose/lib/options/schemaBufferOptions.js +38 -0
- package/templates/node_modules/mongoose/lib/options/schemaDateOptions.js +71 -0
- package/templates/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +68 -0
- package/templates/node_modules/mongoose/lib/options/schemaMapOptions.js +43 -0
- package/templates/node_modules/mongoose/lib/options/schemaNumberOptions.js +101 -0
- package/templates/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +64 -0
- package/templates/node_modules/mongoose/lib/options/schemaStringOptions.js +138 -0
- package/templates/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +66 -0
- package/templates/node_modules/mongoose/lib/options/schemaTypeOptions.js +244 -0
- package/templates/node_modules/mongoose/lib/options/schemaUnionOptions.js +32 -0
- package/templates/node_modules/mongoose/lib/options/virtualOptions.js +164 -0
- package/templates/node_modules/mongoose/lib/options.js +17 -0
- package/templates/node_modules/mongoose/lib/plugins/index.js +6 -0
- package/templates/node_modules/mongoose/lib/plugins/saveSubdocs.js +75 -0
- package/templates/node_modules/mongoose/lib/plugins/sharding.js +84 -0
- package/templates/node_modules/mongoose/lib/plugins/trackTransaction.js +85 -0
- package/templates/node_modules/mongoose/lib/plugins/validateBeforeSave.js +41 -0
- package/templates/node_modules/mongoose/lib/query.js +5649 -0
- package/templates/node_modules/mongoose/lib/queryHelpers.js +390 -0
- package/templates/node_modules/mongoose/lib/schema/array.js +701 -0
- package/templates/node_modules/mongoose/lib/schema/bigint.js +282 -0
- package/templates/node_modules/mongoose/lib/schema/boolean.js +332 -0
- package/templates/node_modules/mongoose/lib/schema/buffer.js +343 -0
- package/templates/node_modules/mongoose/lib/schema/date.js +467 -0
- package/templates/node_modules/mongoose/lib/schema/decimal128.js +263 -0
- package/templates/node_modules/mongoose/lib/schema/documentArray.js +664 -0
- package/templates/node_modules/mongoose/lib/schema/documentArrayElement.js +107 -0
- package/templates/node_modules/mongoose/lib/schema/double.js +246 -0
- package/templates/node_modules/mongoose/lib/schema/index.js +31 -0
- package/templates/node_modules/mongoose/lib/schema/int32.js +289 -0
- package/templates/node_modules/mongoose/lib/schema/map.js +201 -0
- package/templates/node_modules/mongoose/lib/schema/mixed.js +146 -0
- package/templates/node_modules/mongoose/lib/schema/number.js +492 -0
- package/templates/node_modules/mongoose/lib/schema/objectId.js +333 -0
- package/templates/node_modules/mongoose/lib/schema/operators/bitwise.js +38 -0
- package/templates/node_modules/mongoose/lib/schema/operators/exists.js +12 -0
- package/templates/node_modules/mongoose/lib/schema/operators/geospatial.js +107 -0
- package/templates/node_modules/mongoose/lib/schema/operators/helpers.js +32 -0
- package/templates/node_modules/mongoose/lib/schema/operators/text.js +39 -0
- package/templates/node_modules/mongoose/lib/schema/operators/type.js +20 -0
- package/templates/node_modules/mongoose/lib/schema/string.js +733 -0
- package/templates/node_modules/mongoose/lib/schema/subdocument.js +439 -0
- package/templates/node_modules/mongoose/lib/schema/symbols.js +5 -0
- package/templates/node_modules/mongoose/lib/schema/union.js +113 -0
- package/templates/node_modules/mongoose/lib/schema/uuid.js +305 -0
- package/templates/node_modules/mongoose/lib/schema.js +3227 -0
- package/templates/node_modules/mongoose/lib/schemaType.js +1835 -0
- package/templates/node_modules/mongoose/lib/stateMachine.js +232 -0
- package/templates/node_modules/mongoose/lib/types/array/index.js +119 -0
- package/templates/node_modules/mongoose/lib/types/array/isMongooseArray.js +5 -0
- package/templates/node_modules/mongoose/lib/types/array/methods/index.js +1065 -0
- package/templates/node_modules/mongoose/lib/types/arraySubdocument.js +197 -0
- package/templates/node_modules/mongoose/lib/types/buffer.js +294 -0
- package/templates/node_modules/mongoose/lib/types/decimal128.js +13 -0
- package/templates/node_modules/mongoose/lib/types/documentArray/index.js +113 -0
- package/templates/node_modules/mongoose/lib/types/documentArray/isMongooseDocumentArray.js +5 -0
- package/templates/node_modules/mongoose/lib/types/documentArray/methods/index.js +415 -0
- package/templates/node_modules/mongoose/lib/types/double.js +13 -0
- package/templates/node_modules/mongoose/lib/types/index.js +23 -0
- package/templates/node_modules/mongoose/lib/types/map.js +419 -0
- package/templates/node_modules/mongoose/lib/types/objectid.js +41 -0
- package/templates/node_modules/mongoose/lib/types/subdocument.js +454 -0
- package/templates/node_modules/mongoose/lib/types/uuid.js +13 -0
- package/templates/node_modules/mongoose/lib/utils.js +1038 -0
- package/templates/node_modules/mongoose/lib/validOptions.js +42 -0
- package/templates/node_modules/mongoose/lib/virtualType.js +204 -0
- package/templates/node_modules/mongoose/package.json +143 -0
- package/templates/node_modules/mongoose/types/aggregate.d.ts +180 -0
- package/templates/node_modules/mongoose/types/augmentations.d.ts +9 -0
- package/templates/node_modules/mongoose/types/callback.d.ts +8 -0
- package/templates/node_modules/mongoose/types/collection.d.ts +49 -0
- package/templates/node_modules/mongoose/types/connection.d.ts +297 -0
- package/templates/node_modules/mongoose/types/cursor.d.ts +67 -0
- package/templates/node_modules/mongoose/types/document.d.ts +374 -0
- package/templates/node_modules/mongoose/types/error.d.ts +143 -0
- package/templates/node_modules/mongoose/types/expressions.d.ts +3053 -0
- package/templates/node_modules/mongoose/types/helpers.d.ts +32 -0
- package/templates/node_modules/mongoose/types/index.d.ts +1046 -0
- package/templates/node_modules/mongoose/types/indexes.d.ts +97 -0
- package/templates/node_modules/mongoose/types/inferhydrateddoctype.d.ts +115 -0
- package/templates/node_modules/mongoose/types/inferrawdoctype.d.ts +135 -0
- package/templates/node_modules/mongoose/types/inferschematype.d.ts +337 -0
- package/templates/node_modules/mongoose/types/middlewares.d.ts +48 -0
- package/templates/node_modules/mongoose/types/models.d.ts +1291 -0
- package/templates/node_modules/mongoose/types/mongooseoptions.d.ts +228 -0
- package/templates/node_modules/mongoose/types/pipelinestage.d.ts +333 -0
- package/templates/node_modules/mongoose/types/populate.d.ts +53 -0
- package/templates/node_modules/mongoose/types/query.d.ts +934 -0
- package/templates/node_modules/mongoose/types/schemaoptions.d.ts +280 -0
- package/templates/node_modules/mongoose/types/schematypes.d.ts +645 -0
- package/templates/node_modules/mongoose/types/session.d.ts +32 -0
- package/templates/node_modules/mongoose/types/types.d.ts +109 -0
- package/templates/node_modules/mongoose/types/utility.d.ts +175 -0
- package/templates/node_modules/mongoose/types/validation.d.ts +39 -0
- package/templates/node_modules/mongoose/types/virtuals.d.ts +14 -0
- package/templates/node_modules/morgan/HISTORY.md +221 -0
- package/templates/node_modules/morgan/LICENSE +23 -0
- package/templates/node_modules/morgan/README.md +436 -0
- package/templates/node_modules/morgan/index.js +544 -0
- package/templates/node_modules/morgan/node_modules/debug/.coveralls.yml +1 -0
- package/templates/node_modules/morgan/node_modules/debug/.eslintrc +11 -0
- package/templates/node_modules/morgan/node_modules/debug/.travis.yml +14 -0
- package/templates/node_modules/morgan/node_modules/debug/CHANGELOG.md +362 -0
- package/templates/node_modules/morgan/node_modules/debug/LICENSE +19 -0
- package/templates/node_modules/morgan/node_modules/debug/Makefile +50 -0
- package/templates/node_modules/morgan/node_modules/debug/README.md +312 -0
- package/templates/node_modules/morgan/node_modules/debug/component.json +19 -0
- package/templates/node_modules/morgan/node_modules/debug/karma.conf.js +70 -0
- package/templates/node_modules/morgan/node_modules/debug/node.js +1 -0
- package/templates/node_modules/morgan/node_modules/debug/package.json +49 -0
- package/templates/node_modules/morgan/node_modules/debug/src/browser.js +185 -0
- package/templates/node_modules/morgan/node_modules/debug/src/debug.js +202 -0
- package/templates/node_modules/morgan/node_modules/debug/src/index.js +10 -0
- package/templates/node_modules/morgan/node_modules/debug/src/inspector-log.js +15 -0
- package/templates/node_modules/morgan/node_modules/debug/src/node.js +248 -0
- package/templates/node_modules/morgan/node_modules/ms/index.js +152 -0
- package/templates/node_modules/morgan/node_modules/ms/license.md +21 -0
- package/templates/node_modules/morgan/node_modules/ms/package.json +37 -0
- package/templates/node_modules/morgan/node_modules/ms/readme.md +51 -0
- package/templates/node_modules/morgan/node_modules/on-finished/HISTORY.md +88 -0
- package/templates/node_modules/morgan/node_modules/on-finished/LICENSE +23 -0
- package/templates/node_modules/morgan/node_modules/on-finished/README.md +154 -0
- package/templates/node_modules/morgan/node_modules/on-finished/index.js +196 -0
- package/templates/node_modules/morgan/node_modules/on-finished/package.json +31 -0
- package/templates/node_modules/morgan/package.json +52 -0
- package/templates/node_modules/mpath/.travis.yml +9 -0
- package/templates/node_modules/mpath/History.md +88 -0
- package/templates/node_modules/mpath/LICENSE +22 -0
- package/templates/node_modules/mpath/README.md +278 -0
- package/templates/node_modules/mpath/SECURITY.md +5 -0
- package/templates/node_modules/mpath/index.js +3 -0
- package/templates/node_modules/mpath/lib/index.js +336 -0
- package/templates/node_modules/mpath/lib/stringToParts.js +48 -0
- package/templates/node_modules/mpath/package.json +144 -0
- package/templates/node_modules/mpath/test/.eslintrc.yml +4 -0
- package/templates/node_modules/mpath/test/index.js +1879 -0
- package/templates/node_modules/mpath/test/stringToParts.js +30 -0
- package/templates/node_modules/mquery/.github/ISSUE_TEMPLATE.md +11 -0
- package/templates/node_modules/mquery/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/templates/node_modules/mquery/History.md +393 -0
- package/templates/node_modules/mquery/LICENSE +22 -0
- package/templates/node_modules/mquery/README.md +1387 -0
- package/templates/node_modules/mquery/SECURITY.md +1 -0
- package/templates/node_modules/mquery/lib/collection/collection.js +47 -0
- package/templates/node_modules/mquery/lib/collection/index.js +13 -0
- package/templates/node_modules/mquery/lib/collection/node.js +128 -0
- package/templates/node_modules/mquery/lib/env.js +22 -0
- package/templates/node_modules/mquery/lib/mquery.js +2748 -0
- package/templates/node_modules/mquery/lib/permissions.js +93 -0
- package/templates/node_modules/mquery/lib/utils.js +297 -0
- package/templates/node_modules/mquery/package.json +35 -0
- package/templates/node_modules/ms/index.js +162 -0
- package/templates/node_modules/ms/license.md +21 -0
- package/templates/node_modules/ms/package.json +38 -0
- package/templates/node_modules/ms/readme.md +59 -0
- package/templates/node_modules/negotiator/HISTORY.md +114 -0
- package/templates/node_modules/negotiator/LICENSE +24 -0
- package/templates/node_modules/negotiator/README.md +212 -0
- package/templates/node_modules/negotiator/index.js +83 -0
- package/templates/node_modules/negotiator/lib/charset.js +169 -0
- package/templates/node_modules/negotiator/lib/encoding.js +205 -0
- package/templates/node_modules/negotiator/lib/language.js +179 -0
- package/templates/node_modules/negotiator/lib/mediaType.js +294 -0
- package/templates/node_modules/negotiator/package.json +43 -0
- package/templates/node_modules/object-inspect/.eslintrc +53 -0
- package/templates/node_modules/object-inspect/.github/FUNDING.yml +12 -0
- package/templates/node_modules/object-inspect/.nycrc +13 -0
- package/templates/node_modules/object-inspect/CHANGELOG.md +424 -0
- package/templates/node_modules/object-inspect/LICENSE +21 -0
- package/templates/node_modules/object-inspect/example/all.js +23 -0
- package/templates/node_modules/object-inspect/example/circular.js +6 -0
- package/templates/node_modules/object-inspect/example/fn.js +5 -0
- package/templates/node_modules/object-inspect/example/inspect.js +10 -0
- package/templates/node_modules/object-inspect/index.js +544 -0
- package/templates/node_modules/object-inspect/package-support.json +20 -0
- package/templates/node_modules/object-inspect/package.json +105 -0
- package/templates/node_modules/object-inspect/readme.markdown +84 -0
- package/templates/node_modules/object-inspect/test/bigint.js +58 -0
- package/templates/node_modules/object-inspect/test/browser/dom.js +15 -0
- package/templates/node_modules/object-inspect/test/circular.js +16 -0
- package/templates/node_modules/object-inspect/test/deep.js +12 -0
- package/templates/node_modules/object-inspect/test/element.js +53 -0
- package/templates/node_modules/object-inspect/test/err.js +48 -0
- package/templates/node_modules/object-inspect/test/fakes.js +29 -0
- package/templates/node_modules/object-inspect/test/fn.js +76 -0
- package/templates/node_modules/object-inspect/test/global.js +17 -0
- package/templates/node_modules/object-inspect/test/has.js +15 -0
- package/templates/node_modules/object-inspect/test/holes.js +15 -0
- package/templates/node_modules/object-inspect/test/indent-option.js +271 -0
- package/templates/node_modules/object-inspect/test/inspect.js +139 -0
- package/templates/node_modules/object-inspect/test/lowbyte.js +12 -0
- package/templates/node_modules/object-inspect/test/number.js +58 -0
- package/templates/node_modules/object-inspect/test/quoteStyle.js +26 -0
- package/templates/node_modules/object-inspect/test/toStringTag.js +40 -0
- package/templates/node_modules/object-inspect/test/undef.js +12 -0
- package/templates/node_modules/object-inspect/test/values.js +261 -0
- package/templates/node_modules/object-inspect/test-core-js.js +26 -0
- package/templates/node_modules/object-inspect/util.inspect.js +1 -0
- package/templates/node_modules/on-finished/HISTORY.md +98 -0
- package/templates/node_modules/on-finished/LICENSE +23 -0
- package/templates/node_modules/on-finished/README.md +162 -0
- package/templates/node_modules/on-finished/index.js +234 -0
- package/templates/node_modules/on-finished/package.json +39 -0
- package/templates/node_modules/on-headers/HISTORY.md +26 -0
- package/templates/node_modules/on-headers/LICENSE +22 -0
- package/templates/node_modules/on-headers/README.md +81 -0
- package/templates/node_modules/on-headers/index.js +180 -0
- package/templates/node_modules/on-headers/package.json +44 -0
- package/templates/node_modules/once/LICENSE +15 -0
- package/templates/node_modules/once/README.md +79 -0
- package/templates/node_modules/once/once.js +42 -0
- package/templates/node_modules/once/package.json +33 -0
- package/templates/node_modules/parseurl/HISTORY.md +58 -0
- package/templates/node_modules/parseurl/LICENSE +24 -0
- package/templates/node_modules/parseurl/README.md +133 -0
- package/templates/node_modules/parseurl/index.js +158 -0
- package/templates/node_modules/parseurl/package.json +40 -0
- package/templates/node_modules/path-to-regexp/LICENSE +21 -0
- package/templates/node_modules/path-to-regexp/Readme.md +224 -0
- package/templates/node_modules/path-to-regexp/dist/index.d.ts +144 -0
- package/templates/node_modules/path-to-regexp/dist/index.js +409 -0
- package/templates/node_modules/path-to-regexp/dist/index.js.map +1 -0
- package/templates/node_modules/path-to-regexp/package.json +64 -0
- package/templates/node_modules/proxy-addr/HISTORY.md +161 -0
- package/templates/node_modules/proxy-addr/LICENSE +22 -0
- package/templates/node_modules/proxy-addr/README.md +139 -0
- package/templates/node_modules/proxy-addr/index.js +327 -0
- package/templates/node_modules/proxy-addr/package.json +47 -0
- package/templates/node_modules/punycode/LICENSE-MIT.txt +20 -0
- package/templates/node_modules/punycode/README.md +148 -0
- package/templates/node_modules/punycode/package.json +58 -0
- package/templates/node_modules/punycode/punycode.es6.js +444 -0
- package/templates/node_modules/punycode/punycode.js +443 -0
- package/templates/node_modules/qs/.editorconfig +46 -0
- package/templates/node_modules/qs/.eslintrc +39 -0
- package/templates/node_modules/qs/.github/FUNDING.yml +12 -0
- package/templates/node_modules/qs/.nycrc +13 -0
- package/templates/node_modules/qs/CHANGELOG.md +622 -0
- package/templates/node_modules/qs/LICENSE.md +29 -0
- package/templates/node_modules/qs/README.md +733 -0
- package/templates/node_modules/qs/dist/qs.js +141 -0
- package/templates/node_modules/qs/lib/formats.js +23 -0
- package/templates/node_modules/qs/lib/index.js +11 -0
- package/templates/node_modules/qs/lib/parse.js +328 -0
- package/templates/node_modules/qs/lib/stringify.js +356 -0
- package/templates/node_modules/qs/lib/utils.js +268 -0
- package/templates/node_modules/qs/package.json +93 -0
- package/templates/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/templates/node_modules/qs/test/parse.js +1276 -0
- package/templates/node_modules/qs/test/stringify.js +1306 -0
- package/templates/node_modules/qs/test/utils.js +262 -0
- package/templates/node_modules/range-parser/HISTORY.md +56 -0
- package/templates/node_modules/range-parser/LICENSE +23 -0
- package/templates/node_modules/range-parser/README.md +84 -0
- package/templates/node_modules/range-parser/index.js +162 -0
- package/templates/node_modules/range-parser/package.json +44 -0
- package/templates/node_modules/raw-body/LICENSE +22 -0
- package/templates/node_modules/raw-body/README.md +223 -0
- package/templates/node_modules/raw-body/index.d.ts +85 -0
- package/templates/node_modules/raw-body/index.js +336 -0
- package/templates/node_modules/raw-body/package.json +46 -0
- package/templates/node_modules/router/HISTORY.md +228 -0
- package/templates/node_modules/router/LICENSE +23 -0
- package/templates/node_modules/router/README.md +416 -0
- package/templates/node_modules/router/index.js +748 -0
- package/templates/node_modules/router/lib/layer.js +247 -0
- package/templates/node_modules/router/lib/route.js +242 -0
- package/templates/node_modules/router/package.json +44 -0
- package/templates/node_modules/safe-buffer/LICENSE +21 -0
- package/templates/node_modules/safe-buffer/README.md +584 -0
- package/templates/node_modules/safe-buffer/index.d.ts +187 -0
- package/templates/node_modules/safe-buffer/index.js +62 -0
- package/templates/node_modules/safe-buffer/package.json +37 -0
- package/templates/node_modules/safer-buffer/LICENSE +21 -0
- package/templates/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/templates/node_modules/safer-buffer/Readme.md +156 -0
- package/templates/node_modules/safer-buffer/dangerous.js +58 -0
- package/templates/node_modules/safer-buffer/package.json +34 -0
- package/templates/node_modules/safer-buffer/safer.js +77 -0
- package/templates/node_modules/safer-buffer/tests.js +406 -0
- package/templates/node_modules/send/LICENSE +23 -0
- package/templates/node_modules/send/README.md +317 -0
- package/templates/node_modules/send/index.js +997 -0
- package/templates/node_modules/send/package.json +63 -0
- package/templates/node_modules/serve-static/LICENSE +25 -0
- package/templates/node_modules/serve-static/README.md +253 -0
- package/templates/node_modules/serve-static/index.js +208 -0
- package/templates/node_modules/serve-static/package.json +44 -0
- package/templates/node_modules/setprototypeof/LICENSE +13 -0
- package/templates/node_modules/setprototypeof/README.md +31 -0
- package/templates/node_modules/setprototypeof/index.d.ts +2 -0
- package/templates/node_modules/setprototypeof/index.js +17 -0
- package/templates/node_modules/setprototypeof/package.json +38 -0
- package/templates/node_modules/setprototypeof/test/index.js +24 -0
- package/templates/node_modules/side-channel/.editorconfig +9 -0
- package/templates/node_modules/side-channel/.eslintrc +12 -0
- package/templates/node_modules/side-channel/.github/FUNDING.yml +12 -0
- package/templates/node_modules/side-channel/.nycrc +13 -0
- package/templates/node_modules/side-channel/CHANGELOG.md +110 -0
- package/templates/node_modules/side-channel/LICENSE +21 -0
- package/templates/node_modules/side-channel/README.md +61 -0
- package/templates/node_modules/side-channel/index.d.ts +14 -0
- package/templates/node_modules/side-channel/index.js +43 -0
- package/templates/node_modules/side-channel/package.json +85 -0
- package/templates/node_modules/side-channel/test/index.js +104 -0
- package/templates/node_modules/side-channel/tsconfig.json +9 -0
- package/templates/node_modules/side-channel-list/.editorconfig +9 -0
- package/templates/node_modules/side-channel-list/.eslintrc +11 -0
- package/templates/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
- package/templates/node_modules/side-channel-list/.nycrc +13 -0
- package/templates/node_modules/side-channel-list/CHANGELOG.md +15 -0
- package/templates/node_modules/side-channel-list/LICENSE +21 -0
- package/templates/node_modules/side-channel-list/README.md +62 -0
- package/templates/node_modules/side-channel-list/index.d.ts +13 -0
- package/templates/node_modules/side-channel-list/index.js +113 -0
- package/templates/node_modules/side-channel-list/list.d.ts +14 -0
- package/templates/node_modules/side-channel-list/package.json +77 -0
- package/templates/node_modules/side-channel-list/test/index.js +104 -0
- package/templates/node_modules/side-channel-list/tsconfig.json +9 -0
- package/templates/node_modules/side-channel-map/.editorconfig +9 -0
- package/templates/node_modules/side-channel-map/.eslintrc +11 -0
- package/templates/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
- package/templates/node_modules/side-channel-map/.nycrc +13 -0
- package/templates/node_modules/side-channel-map/CHANGELOG.md +22 -0
- package/templates/node_modules/side-channel-map/LICENSE +21 -0
- package/templates/node_modules/side-channel-map/README.md +62 -0
- package/templates/node_modules/side-channel-map/index.d.ts +15 -0
- package/templates/node_modules/side-channel-map/index.js +68 -0
- package/templates/node_modules/side-channel-map/package.json +80 -0
- package/templates/node_modules/side-channel-map/test/index.js +114 -0
- package/templates/node_modules/side-channel-map/tsconfig.json +9 -0
- package/templates/node_modules/side-channel-weakmap/.editorconfig +9 -0
- package/templates/node_modules/side-channel-weakmap/.eslintrc +12 -0
- package/templates/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
- package/templates/node_modules/side-channel-weakmap/.nycrc +13 -0
- package/templates/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
- package/templates/node_modules/side-channel-weakmap/LICENSE +21 -0
- package/templates/node_modules/side-channel-weakmap/README.md +62 -0
- package/templates/node_modules/side-channel-weakmap/index.d.ts +15 -0
- package/templates/node_modules/side-channel-weakmap/index.js +84 -0
- package/templates/node_modules/side-channel-weakmap/package.json +87 -0
- package/templates/node_modules/side-channel-weakmap/test/index.js +114 -0
- package/templates/node_modules/side-channel-weakmap/tsconfig.json +9 -0
- package/templates/node_modules/sift/MIT-LICENSE.txt +20 -0
- package/templates/node_modules/sift/README.md +465 -0
- package/templates/node_modules/sift/es/index.js +632 -0
- package/templates/node_modules/sift/es/index.js.map +1 -0
- package/templates/node_modules/sift/es5m/index.js +743 -0
- package/templates/node_modules/sift/es5m/index.js.map +1 -0
- package/templates/node_modules/sift/index.d.ts +4 -0
- package/templates/node_modules/sift/index.js +4 -0
- package/templates/node_modules/sift/lib/core.d.ts +116 -0
- package/templates/node_modules/sift/lib/index.d.ts +6 -0
- package/templates/node_modules/sift/lib/index.js +781 -0
- package/templates/node_modules/sift/lib/index.js.map +1 -0
- package/templates/node_modules/sift/lib/operations.d.ts +88 -0
- package/templates/node_modules/sift/lib/utils.d.ts +11 -0
- package/templates/node_modules/sift/package.json +61 -0
- package/templates/node_modules/sift/sift.csp.min.js +778 -0
- package/templates/node_modules/sift/sift.csp.min.js.map +1 -0
- package/templates/node_modules/sift/sift.min.js +2 -0
- package/templates/node_modules/sift/sift.min.js.map +1 -0
- package/templates/node_modules/sift/src/core.ts +494 -0
- package/templates/node_modules/sift/src/index.ts +54 -0
- package/templates/node_modules/sift/src/operations.ts +422 -0
- package/templates/node_modules/sift/src/utils.ts +74 -0
- package/templates/node_modules/sparse-bitfield/.travis.yml +6 -0
- package/templates/node_modules/sparse-bitfield/LICENSE +21 -0
- package/templates/node_modules/sparse-bitfield/README.md +62 -0
- package/templates/node_modules/sparse-bitfield/index.js +95 -0
- package/templates/node_modules/sparse-bitfield/package.json +27 -0
- package/templates/node_modules/sparse-bitfield/test.js +79 -0
- package/templates/node_modules/statuses/HISTORY.md +87 -0
- package/templates/node_modules/statuses/LICENSE +23 -0
- package/templates/node_modules/statuses/README.md +139 -0
- package/templates/node_modules/statuses/codes.json +65 -0
- package/templates/node_modules/statuses/index.js +146 -0
- package/templates/node_modules/statuses/package.json +49 -0
- package/templates/node_modules/toidentifier/HISTORY.md +9 -0
- package/templates/node_modules/toidentifier/LICENSE +21 -0
- package/templates/node_modules/toidentifier/README.md +61 -0
- package/templates/node_modules/toidentifier/index.js +32 -0
- package/templates/node_modules/toidentifier/package.json +38 -0
- package/templates/node_modules/tr46/LICENSE.md +21 -0
- package/templates/node_modules/tr46/README.md +76 -0
- package/templates/node_modules/tr46/index.js +344 -0
- package/templates/node_modules/tr46/lib/mappingTable.json +1 -0
- package/templates/node_modules/tr46/lib/regexes.js +29 -0
- package/templates/node_modules/tr46/lib/statusMapping.js +9 -0
- package/templates/node_modules/tr46/package.json +44 -0
- package/templates/node_modules/type-is/HISTORY.md +292 -0
- package/templates/node_modules/type-is/LICENSE +23 -0
- package/templates/node_modules/type-is/README.md +198 -0
- package/templates/node_modules/type-is/index.js +250 -0
- package/templates/node_modules/type-is/package.json +47 -0
- package/templates/node_modules/unpipe/HISTORY.md +4 -0
- package/templates/node_modules/unpipe/LICENSE +22 -0
- package/templates/node_modules/unpipe/README.md +43 -0
- package/templates/node_modules/unpipe/index.js +69 -0
- package/templates/node_modules/unpipe/package.json +27 -0
- package/templates/node_modules/vary/HISTORY.md +39 -0
- package/templates/node_modules/vary/LICENSE +22 -0
- package/templates/node_modules/vary/README.md +101 -0
- package/templates/node_modules/vary/index.js +149 -0
- package/templates/node_modules/vary/package.json +43 -0
- package/templates/node_modules/webidl-conversions/LICENSE.md +12 -0
- package/templates/node_modules/webidl-conversions/README.md +99 -0
- package/templates/node_modules/webidl-conversions/lib/index.js +450 -0
- package/templates/node_modules/webidl-conversions/package.json +35 -0
- package/templates/node_modules/whatwg-url/LICENSE.txt +21 -0
- package/templates/node_modules/whatwg-url/README.md +106 -0
- package/templates/node_modules/whatwg-url/index.js +27 -0
- package/templates/node_modules/whatwg-url/lib/Function.js +42 -0
- package/templates/node_modules/whatwg-url/lib/URL-impl.js +233 -0
- package/templates/node_modules/whatwg-url/lib/URL.js +499 -0
- package/templates/node_modules/whatwg-url/lib/URLSearchParams-impl.js +135 -0
- package/templates/node_modules/whatwg-url/lib/URLSearchParams.js +505 -0
- package/templates/node_modules/whatwg-url/lib/VoidFunction.js +26 -0
- package/templates/node_modules/whatwg-url/lib/encoding.js +16 -0
- package/templates/node_modules/whatwg-url/lib/infra.js +26 -0
- package/templates/node_modules/whatwg-url/lib/percent-encoding.js +142 -0
- package/templates/node_modules/whatwg-url/lib/url-state-machine.js +1274 -0
- package/templates/node_modules/whatwg-url/lib/urlencoded.js +89 -0
- package/templates/node_modules/whatwg-url/lib/utils.js +190 -0
- package/templates/node_modules/whatwg-url/package.json +53 -0
- package/templates/node_modules/whatwg-url/webidl2js-wrapper.js +7 -0
- package/templates/node_modules/wrappy/LICENSE +15 -0
- package/templates/node_modules/wrappy/README.md +36 -0
- package/templates/node_modules/wrappy/package.json +29 -0
- package/templates/node_modules/wrappy/wrappy.js +33 -0
- package/templates/package-lock.json +23 -0
- package/templates/package.json +1 -0
- package/templates/server.js +7 -8
- package/test-proj/db/index.js +0 -15
- package/test-proj/package.json +0 -19
- package/test-proj/server.js +0 -55
|
@@ -0,0 +1,2748 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dependencies
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const assert = require('assert');
|
|
8
|
+
const util = require('util');
|
|
9
|
+
const utils = require('./utils');
|
|
10
|
+
|
|
11
|
+
const debug = util.debuglog('mquery');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Query constructor used for building queries.
|
|
15
|
+
*
|
|
16
|
+
* #### Example:
|
|
17
|
+
*
|
|
18
|
+
* var query = new Query({ name: 'mquery' });
|
|
19
|
+
* query.setOptions({ collection: moduleCollection })
|
|
20
|
+
* await query.where('age').gte(21).exec();
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} [criteria] criteria for the query OR the collection instance to use
|
|
23
|
+
* @param {Object} [options]
|
|
24
|
+
* @api public
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function Query(criteria, options) {
|
|
28
|
+
if (!(this instanceof Query))
|
|
29
|
+
return new Query(criteria, options);
|
|
30
|
+
|
|
31
|
+
const proto = this.constructor.prototype;
|
|
32
|
+
|
|
33
|
+
this.op = proto.op || undefined;
|
|
34
|
+
|
|
35
|
+
this.options = Object.assign({}, proto.options);
|
|
36
|
+
|
|
37
|
+
this._conditions = proto._conditions
|
|
38
|
+
? utils.clone(proto._conditions)
|
|
39
|
+
: {};
|
|
40
|
+
|
|
41
|
+
this._fields = proto._fields
|
|
42
|
+
? utils.clone(proto._fields)
|
|
43
|
+
: undefined;
|
|
44
|
+
|
|
45
|
+
this._updateDoc = proto._updateDoc
|
|
46
|
+
? utils.clone(proto._updateDoc)
|
|
47
|
+
: undefined;
|
|
48
|
+
|
|
49
|
+
this._path = proto._path || undefined;
|
|
50
|
+
this._distinctDoc = proto._distinctDoc || undefined;
|
|
51
|
+
this._collection = proto._collection || undefined;
|
|
52
|
+
this._traceFunction = proto._traceFunction || undefined;
|
|
53
|
+
|
|
54
|
+
if (options) {
|
|
55
|
+
this.setOptions(options);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (criteria) {
|
|
59
|
+
this.find(criteria);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Converts this query to a constructor function with all arguments and options retained.
|
|
65
|
+
*
|
|
66
|
+
* #### Example:
|
|
67
|
+
*
|
|
68
|
+
* // Create a query that will read documents with a "video" category from
|
|
69
|
+
* // `aCollection` on the primary node in the replica-set unless it is down,
|
|
70
|
+
* // in which case we'll read from a secondary node.
|
|
71
|
+
* var query = mquery({ category: 'video' })
|
|
72
|
+
* query.setOptions({ collection: aCollection, read: 'primaryPreferred' });
|
|
73
|
+
*
|
|
74
|
+
* // create a constructor based off these settings
|
|
75
|
+
* var Video = query.toConstructor();
|
|
76
|
+
*
|
|
77
|
+
* // Video is now a subclass of mquery() and works the same way but with the
|
|
78
|
+
* // default query parameters and options set.
|
|
79
|
+
*
|
|
80
|
+
* // run a query with the previous settings but filter for movies with names
|
|
81
|
+
* // that start with "Life".
|
|
82
|
+
* Video().where({ name: /^Life/ }).exec(cb);
|
|
83
|
+
*
|
|
84
|
+
* @return {Query} new Query
|
|
85
|
+
* @api public
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
Query.prototype.toConstructor = function toConstructor() {
|
|
89
|
+
function CustomQuery(criteria, options) {
|
|
90
|
+
if (!(this instanceof CustomQuery))
|
|
91
|
+
return new CustomQuery(criteria, options);
|
|
92
|
+
Query.call(this, criteria, options);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
utils.inherits(CustomQuery, Query);
|
|
96
|
+
|
|
97
|
+
// set inherited defaults
|
|
98
|
+
const p = CustomQuery.prototype;
|
|
99
|
+
|
|
100
|
+
p.options = {};
|
|
101
|
+
p.setOptions(this.options);
|
|
102
|
+
|
|
103
|
+
p.op = this.op;
|
|
104
|
+
p._conditions = utils.clone(this._conditions);
|
|
105
|
+
p._fields = utils.clone(this._fields);
|
|
106
|
+
p._updateDoc = utils.clone(this._updateDoc);
|
|
107
|
+
p._path = this._path;
|
|
108
|
+
p._distinctDoc = this._distinctDoc;
|
|
109
|
+
p._collection = this._collection;
|
|
110
|
+
p._traceFunction = this._traceFunction;
|
|
111
|
+
|
|
112
|
+
return CustomQuery;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Sets query options.
|
|
117
|
+
*
|
|
118
|
+
* #### Options:
|
|
119
|
+
*
|
|
120
|
+
* - [tailable](http://www.mongodb.org/display/DOCS/Tailable+Cursors) *
|
|
121
|
+
* - [sort](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsort(\)%7D%7D) *
|
|
122
|
+
* - [limit](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D) *
|
|
123
|
+
* - [skip](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D) *
|
|
124
|
+
* - [maxTime](http://docs.mongodb.org/manual/reference/operator/meta/maxTimeMS/#op._S_maxTimeMS) *
|
|
125
|
+
* - [batchSize](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D) *
|
|
126
|
+
* - [comment](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment) *
|
|
127
|
+
* - [hint](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint) *
|
|
128
|
+
* - [slaveOk](http://docs.mongodb.org/manual/applications/replication/#read-preference) *
|
|
129
|
+
* - [safe](http://www.mongodb.org/display/DOCS/getLastError+Command)
|
|
130
|
+
* - collection the collection to query against
|
|
131
|
+
*
|
|
132
|
+
* _* denotes a query helper method is also available_
|
|
133
|
+
*
|
|
134
|
+
* @param {Object} options
|
|
135
|
+
* @api public
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
Query.prototype.setOptions = function(options) {
|
|
139
|
+
if (!(options && utils.isObject(options)))
|
|
140
|
+
return this;
|
|
141
|
+
|
|
142
|
+
// set arbitrary options
|
|
143
|
+
const methods = utils.keys(options);
|
|
144
|
+
let method;
|
|
145
|
+
|
|
146
|
+
for (let i = 0; i < methods.length; ++i) {
|
|
147
|
+
method = methods[i];
|
|
148
|
+
|
|
149
|
+
// use methods if exist (safer option manipulation)
|
|
150
|
+
if ('function' == typeof this[method]) {
|
|
151
|
+
const args = Array.isArray(options[method])
|
|
152
|
+
? options[method]
|
|
153
|
+
: [options[method]];
|
|
154
|
+
this[method].apply(this, args);
|
|
155
|
+
} else {
|
|
156
|
+
this.options[method] = options[method];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return this;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Sets this Querys collection.
|
|
165
|
+
*
|
|
166
|
+
* @param {Collection} coll
|
|
167
|
+
* @return {Query} this
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
Query.prototype.collection = function collection(coll) {
|
|
171
|
+
this._collection = new Query.Collection(coll);
|
|
172
|
+
|
|
173
|
+
return this;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Adds a collation to this op (MongoDB 3.4 and up)
|
|
178
|
+
*
|
|
179
|
+
* #### Example:
|
|
180
|
+
*
|
|
181
|
+
* query.find().collation({ locale: "en_US", strength: 1 })
|
|
182
|
+
*
|
|
183
|
+
* @param {Object} value
|
|
184
|
+
* @return {Query} this
|
|
185
|
+
* @see MongoDB docs https://docs.mongodb.com/manual/reference/method/cursor.collation/#cursor.collation
|
|
186
|
+
* @api public
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
Query.prototype.collation = function(value) {
|
|
190
|
+
this.options.collation = value;
|
|
191
|
+
return this;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Specifies a `$where` condition
|
|
196
|
+
*
|
|
197
|
+
* Use `$where` when you need to select documents using a JavaScript expression.
|
|
198
|
+
*
|
|
199
|
+
* #### Example:
|
|
200
|
+
*
|
|
201
|
+
* query.$where('this.comments.length > 10 || this.name.length > 5')
|
|
202
|
+
*
|
|
203
|
+
* query.$where(function () {
|
|
204
|
+
* return this.comments.length > 10 || this.name.length > 5;
|
|
205
|
+
* })
|
|
206
|
+
*
|
|
207
|
+
* @param {String|Function} js javascript string or function
|
|
208
|
+
* @return {Query} this
|
|
209
|
+
* @memberOf Query
|
|
210
|
+
* @method $where
|
|
211
|
+
* @api public
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
Query.prototype.$where = function(js) {
|
|
215
|
+
this._conditions.$where = js;
|
|
216
|
+
return this;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Specifies a `path` for use with chaining.
|
|
221
|
+
*
|
|
222
|
+
* #### Example:
|
|
223
|
+
*
|
|
224
|
+
* // instead of writing:
|
|
225
|
+
* await User.find({age: {$gte: 21, $lte: 65}});
|
|
226
|
+
*
|
|
227
|
+
* // we can instead write:
|
|
228
|
+
* User.where('age').gte(21).lte(65);
|
|
229
|
+
*
|
|
230
|
+
* // passing query conditions is permitted
|
|
231
|
+
* User.find().where({ name: 'vonderful' })
|
|
232
|
+
*
|
|
233
|
+
* // chaining
|
|
234
|
+
* await User
|
|
235
|
+
* .where('age').gte(21).lte(65)
|
|
236
|
+
* .where('name', /^vonderful/i)
|
|
237
|
+
* .where('friends').slice(10)
|
|
238
|
+
* .exec()
|
|
239
|
+
*
|
|
240
|
+
* @param {String} [path]
|
|
241
|
+
* @param {Object} [val]
|
|
242
|
+
* @return {Query} this
|
|
243
|
+
* @api public
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
Query.prototype.where = function() {
|
|
247
|
+
if (!arguments.length) return this;
|
|
248
|
+
if (!this.op) this.op = 'find';
|
|
249
|
+
|
|
250
|
+
const type = typeof arguments[0];
|
|
251
|
+
|
|
252
|
+
if ('string' == type) {
|
|
253
|
+
this._path = arguments[0];
|
|
254
|
+
|
|
255
|
+
if (2 === arguments.length) {
|
|
256
|
+
this._conditions[this._path] = arguments[1];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if ('object' == type && !Array.isArray(arguments[0])) {
|
|
263
|
+
return this.merge(arguments[0]);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
throw new TypeError('path must be a string or object');
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Specifies the complementary comparison value for paths specified with `where()`
|
|
271
|
+
*
|
|
272
|
+
* #### Example:
|
|
273
|
+
*
|
|
274
|
+
* User.where('age').equals(49);
|
|
275
|
+
*
|
|
276
|
+
* // is the same as
|
|
277
|
+
*
|
|
278
|
+
* User.where('age', 49);
|
|
279
|
+
*
|
|
280
|
+
* @param {Object} val
|
|
281
|
+
* @return {Query} this
|
|
282
|
+
* @api public
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
Query.prototype.equals = function equals(val) {
|
|
286
|
+
this._ensurePath('equals');
|
|
287
|
+
const path = this._path;
|
|
288
|
+
this._conditions[path] = val;
|
|
289
|
+
return this;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Specifies the complementary comparison value for paths specified with `where()`
|
|
294
|
+
* This is alias of `equals`
|
|
295
|
+
*
|
|
296
|
+
* #### Example:
|
|
297
|
+
*
|
|
298
|
+
* User.where('age').eq(49);
|
|
299
|
+
*
|
|
300
|
+
* // is the same as
|
|
301
|
+
*
|
|
302
|
+
* User.shere('age').equals(49);
|
|
303
|
+
*
|
|
304
|
+
* // is the same as
|
|
305
|
+
*
|
|
306
|
+
* User.where('age', 49);
|
|
307
|
+
*
|
|
308
|
+
* @param {Object} val
|
|
309
|
+
* @return {Query} this
|
|
310
|
+
* @api public
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
Query.prototype.eq = function eq(val) {
|
|
314
|
+
this._ensurePath('eq');
|
|
315
|
+
const path = this._path;
|
|
316
|
+
this._conditions[path] = val;
|
|
317
|
+
return this;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Specifies arguments for an `$or` condition.
|
|
322
|
+
*
|
|
323
|
+
* #### Example:
|
|
324
|
+
*
|
|
325
|
+
* query.or([{ color: 'red' }, { status: 'emergency' }])
|
|
326
|
+
*
|
|
327
|
+
* @param {Array} array array of conditions
|
|
328
|
+
* @return {Query} this
|
|
329
|
+
* @api public
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
Query.prototype.or = function or(array) {
|
|
333
|
+
const or = this._conditions.$or || (this._conditions.$or = []);
|
|
334
|
+
if (!Array.isArray(array)) array = [array];
|
|
335
|
+
or.push.apply(or, array);
|
|
336
|
+
return this;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Specifies arguments for a `$nor` condition.
|
|
341
|
+
*
|
|
342
|
+
* #### Example:
|
|
343
|
+
*
|
|
344
|
+
* query.nor([{ color: 'green' }, { status: 'ok' }])
|
|
345
|
+
*
|
|
346
|
+
* @param {Array} array array of conditions
|
|
347
|
+
* @return {Query} this
|
|
348
|
+
* @api public
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
Query.prototype.nor = function nor(array) {
|
|
352
|
+
const nor = this._conditions.$nor || (this._conditions.$nor = []);
|
|
353
|
+
if (!Array.isArray(array)) array = [array];
|
|
354
|
+
nor.push.apply(nor, array);
|
|
355
|
+
return this;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Specifies arguments for a `$and` condition.
|
|
360
|
+
*
|
|
361
|
+
* #### Example:
|
|
362
|
+
*
|
|
363
|
+
* query.and([{ color: 'green' }, { status: 'ok' }])
|
|
364
|
+
*
|
|
365
|
+
* @see $and http://docs.mongodb.org/manual/reference/operator/and/
|
|
366
|
+
* @param {Array} array array of conditions
|
|
367
|
+
* @return {Query} this
|
|
368
|
+
* @api public
|
|
369
|
+
*/
|
|
370
|
+
|
|
371
|
+
Query.prototype.and = function and(array) {
|
|
372
|
+
const and = this._conditions.$and || (this._conditions.$and = []);
|
|
373
|
+
if (!Array.isArray(array)) array = [array];
|
|
374
|
+
and.push.apply(and, array);
|
|
375
|
+
return this;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Specifies a $gt query condition.
|
|
380
|
+
*
|
|
381
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
382
|
+
*
|
|
383
|
+
* #### Example:
|
|
384
|
+
*
|
|
385
|
+
* Thing.find().where('age').gt(21)
|
|
386
|
+
*
|
|
387
|
+
* // or
|
|
388
|
+
* Thing.find().gt('age', 21)
|
|
389
|
+
*
|
|
390
|
+
* @method gt
|
|
391
|
+
* @memberOf Query
|
|
392
|
+
* @param {String} [path]
|
|
393
|
+
* @param {Number} val
|
|
394
|
+
* @api public
|
|
395
|
+
*/
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Specifies a $gte query condition.
|
|
399
|
+
*
|
|
400
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
401
|
+
*
|
|
402
|
+
* @method gte
|
|
403
|
+
* @memberOf Query
|
|
404
|
+
* @param {String} [path]
|
|
405
|
+
* @param {Number} val
|
|
406
|
+
* @api public
|
|
407
|
+
*/
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Specifies a $lt query condition.
|
|
411
|
+
*
|
|
412
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
413
|
+
*
|
|
414
|
+
* @method lt
|
|
415
|
+
* @memberOf Query
|
|
416
|
+
* @param {String} [path]
|
|
417
|
+
* @param {Number} val
|
|
418
|
+
* @api public
|
|
419
|
+
*/
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Specifies a $lte query condition.
|
|
423
|
+
*
|
|
424
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
425
|
+
*
|
|
426
|
+
* @method lte
|
|
427
|
+
* @memberOf Query
|
|
428
|
+
* @param {String} [path]
|
|
429
|
+
* @param {Number} val
|
|
430
|
+
* @api public
|
|
431
|
+
*/
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Specifies a $ne query condition.
|
|
435
|
+
*
|
|
436
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
437
|
+
*
|
|
438
|
+
* @method ne
|
|
439
|
+
* @memberOf Query
|
|
440
|
+
* @param {String} [path]
|
|
441
|
+
* @param {Number} val
|
|
442
|
+
* @api public
|
|
443
|
+
*/
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Specifies an $in query condition.
|
|
447
|
+
*
|
|
448
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
449
|
+
*
|
|
450
|
+
* @method in
|
|
451
|
+
* @memberOf Query
|
|
452
|
+
* @param {String} [path]
|
|
453
|
+
* @param {Number} val
|
|
454
|
+
* @api public
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Specifies an $nin query condition.
|
|
459
|
+
*
|
|
460
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
461
|
+
*
|
|
462
|
+
* @method nin
|
|
463
|
+
* @memberOf Query
|
|
464
|
+
* @param {String} [path]
|
|
465
|
+
* @param {Number} val
|
|
466
|
+
* @api public
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Specifies an $all query condition.
|
|
471
|
+
*
|
|
472
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
473
|
+
*
|
|
474
|
+
* @method all
|
|
475
|
+
* @memberOf Query
|
|
476
|
+
* @param {String} [path]
|
|
477
|
+
* @param {Number} val
|
|
478
|
+
* @api public
|
|
479
|
+
*/
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Specifies a $size query condition.
|
|
483
|
+
*
|
|
484
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
485
|
+
*
|
|
486
|
+
* @method size
|
|
487
|
+
* @memberOf Query
|
|
488
|
+
* @param {String} [path]
|
|
489
|
+
* @param {Number} val
|
|
490
|
+
* @api public
|
|
491
|
+
*/
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Specifies a $regex query condition.
|
|
495
|
+
*
|
|
496
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
497
|
+
*
|
|
498
|
+
* @method regex
|
|
499
|
+
* @memberOf Query
|
|
500
|
+
* @param {String} [path]
|
|
501
|
+
* @param {String|RegExp} val
|
|
502
|
+
* @api public
|
|
503
|
+
*/
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Specifies a $maxDistance query condition.
|
|
507
|
+
*
|
|
508
|
+
* When called with one argument, the most recent path passed to `where()` is used.
|
|
509
|
+
*
|
|
510
|
+
* @method maxDistance
|
|
511
|
+
* @memberOf Query
|
|
512
|
+
* @param {String} [path]
|
|
513
|
+
* @param {Number} val
|
|
514
|
+
* @api public
|
|
515
|
+
*/
|
|
516
|
+
|
|
517
|
+
/*!
|
|
518
|
+
* gt, gte, lt, lte, ne, in, nin, all, regex, size, maxDistance
|
|
519
|
+
*
|
|
520
|
+
* Thing.where('type').nin(array)
|
|
521
|
+
*/
|
|
522
|
+
|
|
523
|
+
'gt gte lt lte ne in nin all regex size maxDistance minDistance'.split(' ').forEach(function($conditional) {
|
|
524
|
+
Query.prototype[$conditional] = function() {
|
|
525
|
+
let path, val;
|
|
526
|
+
|
|
527
|
+
if (1 === arguments.length) {
|
|
528
|
+
this._ensurePath($conditional);
|
|
529
|
+
val = arguments[0];
|
|
530
|
+
path = this._path;
|
|
531
|
+
} else {
|
|
532
|
+
val = arguments[1];
|
|
533
|
+
path = arguments[0];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const conds = this._conditions[path] === null || typeof this._conditions[path] === 'object' ?
|
|
537
|
+
this._conditions[path] :
|
|
538
|
+
(this._conditions[path] = {});
|
|
539
|
+
conds['$' + $conditional] = val;
|
|
540
|
+
return this;
|
|
541
|
+
};
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Specifies a `$mod` condition
|
|
546
|
+
*
|
|
547
|
+
* @param {String} [path]
|
|
548
|
+
* @param {Number} val
|
|
549
|
+
* @return {Query} this
|
|
550
|
+
* @api public
|
|
551
|
+
*/
|
|
552
|
+
|
|
553
|
+
Query.prototype.mod = function() {
|
|
554
|
+
let val, path;
|
|
555
|
+
|
|
556
|
+
if (1 === arguments.length) {
|
|
557
|
+
this._ensurePath('mod');
|
|
558
|
+
val = arguments[0];
|
|
559
|
+
path = this._path;
|
|
560
|
+
} else if (2 === arguments.length && !Array.isArray(arguments[1])) {
|
|
561
|
+
this._ensurePath('mod');
|
|
562
|
+
val = [arguments[0], arguments[1]];
|
|
563
|
+
path = this._path;
|
|
564
|
+
} else if (3 === arguments.length) {
|
|
565
|
+
val = [arguments[1], arguments[2]];
|
|
566
|
+
path = arguments[0];
|
|
567
|
+
} else {
|
|
568
|
+
val = arguments[1];
|
|
569
|
+
path = arguments[0];
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
573
|
+
conds.$mod = val;
|
|
574
|
+
return this;
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Specifies an `$exists` condition
|
|
579
|
+
*
|
|
580
|
+
* #### Example:
|
|
581
|
+
*
|
|
582
|
+
* // { name: { $exists: true }}
|
|
583
|
+
* Thing.where('name').exists()
|
|
584
|
+
* Thing.where('name').exists(true)
|
|
585
|
+
* Thing.find().exists('name')
|
|
586
|
+
*
|
|
587
|
+
* // { name: { $exists: false }}
|
|
588
|
+
* Thing.where('name').exists(false);
|
|
589
|
+
* Thing.find().exists('name', false);
|
|
590
|
+
*
|
|
591
|
+
* @param {String} [path]
|
|
592
|
+
* @param {Number} val
|
|
593
|
+
* @return {Query} this
|
|
594
|
+
* @api public
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
Query.prototype.exists = function() {
|
|
598
|
+
let path, val;
|
|
599
|
+
|
|
600
|
+
if (0 === arguments.length) {
|
|
601
|
+
this._ensurePath('exists');
|
|
602
|
+
path = this._path;
|
|
603
|
+
val = true;
|
|
604
|
+
} else if (1 === arguments.length) {
|
|
605
|
+
if ('boolean' === typeof arguments[0]) {
|
|
606
|
+
this._ensurePath('exists');
|
|
607
|
+
path = this._path;
|
|
608
|
+
val = arguments[0];
|
|
609
|
+
} else {
|
|
610
|
+
path = arguments[0];
|
|
611
|
+
val = true;
|
|
612
|
+
}
|
|
613
|
+
} else if (2 === arguments.length) {
|
|
614
|
+
path = arguments[0];
|
|
615
|
+
val = arguments[1];
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
619
|
+
conds.$exists = val;
|
|
620
|
+
return this;
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Specifies an `$elemMatch` condition
|
|
625
|
+
*
|
|
626
|
+
* #### Example:
|
|
627
|
+
*
|
|
628
|
+
* query.elemMatch('comment', { author: 'autobot', votes: {$gte: 5}})
|
|
629
|
+
*
|
|
630
|
+
* query.where('comment').elemMatch({ author: 'autobot', votes: {$gte: 5}})
|
|
631
|
+
*
|
|
632
|
+
* query.elemMatch('comment', function (elem) {
|
|
633
|
+
* elem.where('author').equals('autobot');
|
|
634
|
+
* elem.where('votes').gte(5);
|
|
635
|
+
* })
|
|
636
|
+
*
|
|
637
|
+
* query.where('comment').elemMatch(function (elem) {
|
|
638
|
+
* elem.where({ author: 'autobot' });
|
|
639
|
+
* elem.where('votes').gte(5);
|
|
640
|
+
* })
|
|
641
|
+
*
|
|
642
|
+
* @param {String|Object|Function} path
|
|
643
|
+
* @param {Object|Function} criteria
|
|
644
|
+
* @return {Query} this
|
|
645
|
+
* @api public
|
|
646
|
+
*/
|
|
647
|
+
|
|
648
|
+
Query.prototype.elemMatch = function() {
|
|
649
|
+
if (null == arguments[0])
|
|
650
|
+
throw new TypeError('Invalid argument');
|
|
651
|
+
|
|
652
|
+
let fn, path, criteria;
|
|
653
|
+
|
|
654
|
+
if ('function' === typeof arguments[0]) {
|
|
655
|
+
this._ensurePath('elemMatch');
|
|
656
|
+
path = this._path;
|
|
657
|
+
fn = arguments[0];
|
|
658
|
+
} else if (utils.isObject(arguments[0])) {
|
|
659
|
+
this._ensurePath('elemMatch');
|
|
660
|
+
path = this._path;
|
|
661
|
+
criteria = arguments[0];
|
|
662
|
+
} else if ('function' === typeof arguments[1]) {
|
|
663
|
+
path = arguments[0];
|
|
664
|
+
fn = arguments[1];
|
|
665
|
+
} else if (arguments[1] && utils.isObject(arguments[1])) {
|
|
666
|
+
path = arguments[0];
|
|
667
|
+
criteria = arguments[1];
|
|
668
|
+
} else {
|
|
669
|
+
throw new TypeError('Invalid argument');
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (fn) {
|
|
673
|
+
criteria = new Query;
|
|
674
|
+
fn(criteria);
|
|
675
|
+
criteria = criteria._conditions;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
679
|
+
conds.$elemMatch = criteria;
|
|
680
|
+
return this;
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// Spatial queries
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Sugar for geo-spatial queries.
|
|
687
|
+
*
|
|
688
|
+
* #### Example:
|
|
689
|
+
*
|
|
690
|
+
* query.within().box()
|
|
691
|
+
* query.within().circle()
|
|
692
|
+
* query.within().geometry()
|
|
693
|
+
*
|
|
694
|
+
* query.where('loc').within({ center: [50,50], radius: 10, unique: true, spherical: true });
|
|
695
|
+
* query.where('loc').within({ box: [[40.73, -73.9], [40.7, -73.988]] });
|
|
696
|
+
* query.where('loc').within({ polygon: [[],[],[],[]] });
|
|
697
|
+
*
|
|
698
|
+
* query.where('loc').within([], [], []) // polygon
|
|
699
|
+
* query.where('loc').within([], []) // box
|
|
700
|
+
* query.where('loc').within({ type: 'LineString', coordinates: [...] }); // geometry
|
|
701
|
+
*
|
|
702
|
+
* #### Note:
|
|
703
|
+
*
|
|
704
|
+
* Must be used after `where()`.
|
|
705
|
+
*
|
|
706
|
+
* @memberOf Query
|
|
707
|
+
* @return {Query} this
|
|
708
|
+
* @api public
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
Query.prototype.within = function within() {
|
|
712
|
+
// opinionated, must be used after where
|
|
713
|
+
this._ensurePath('within');
|
|
714
|
+
this._geoComparison = '$geoWithin';
|
|
715
|
+
|
|
716
|
+
if (0 === arguments.length) {
|
|
717
|
+
return this;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (2 === arguments.length) {
|
|
721
|
+
return this.box.apply(this, arguments);
|
|
722
|
+
} else if (2 < arguments.length) {
|
|
723
|
+
return this.polygon.apply(this, arguments);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
const area = arguments[0];
|
|
727
|
+
|
|
728
|
+
if (!area)
|
|
729
|
+
throw new TypeError('Invalid argument');
|
|
730
|
+
|
|
731
|
+
if (area.center)
|
|
732
|
+
return this.circle(area);
|
|
733
|
+
|
|
734
|
+
if (area.box)
|
|
735
|
+
return this.box.apply(this, area.box);
|
|
736
|
+
|
|
737
|
+
if (area.polygon)
|
|
738
|
+
return this.polygon.apply(this, area.polygon);
|
|
739
|
+
|
|
740
|
+
if (area.type && area.coordinates)
|
|
741
|
+
return this.geometry(area);
|
|
742
|
+
|
|
743
|
+
throw new TypeError('Invalid argument');
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Specifies a $box condition
|
|
748
|
+
*
|
|
749
|
+
* #### Example:
|
|
750
|
+
*
|
|
751
|
+
* var lowerLeft = [40.73083, -73.99756]
|
|
752
|
+
* var upperRight= [40.741404, -73.988135]
|
|
753
|
+
*
|
|
754
|
+
* query.where('loc').within().box(lowerLeft, upperRight)
|
|
755
|
+
* query.box('loc', lowerLeft, upperRight )
|
|
756
|
+
*
|
|
757
|
+
* @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
|
|
758
|
+
* @see Query#within #query_Query-within
|
|
759
|
+
* @param {String} path
|
|
760
|
+
* @param {Object} val
|
|
761
|
+
* @return {Query} this
|
|
762
|
+
* @api public
|
|
763
|
+
*/
|
|
764
|
+
|
|
765
|
+
Query.prototype.box = function() {
|
|
766
|
+
let path, box;
|
|
767
|
+
|
|
768
|
+
if (3 === arguments.length) {
|
|
769
|
+
// box('loc', [], [])
|
|
770
|
+
path = arguments[0];
|
|
771
|
+
box = [arguments[1], arguments[2]];
|
|
772
|
+
} else if (2 === arguments.length) {
|
|
773
|
+
// box([], [])
|
|
774
|
+
this._ensurePath('box');
|
|
775
|
+
path = this._path;
|
|
776
|
+
box = [arguments[0], arguments[1]];
|
|
777
|
+
} else {
|
|
778
|
+
throw new TypeError('Invalid argument');
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
782
|
+
conds[this._geoComparison || '$geoWithin'] = { $box: box };
|
|
783
|
+
return this;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Specifies a $polygon condition
|
|
788
|
+
*
|
|
789
|
+
* #### Example:
|
|
790
|
+
*
|
|
791
|
+
* query.where('loc').within().polygon([10,20], [13, 25], [7,15])
|
|
792
|
+
* query.polygon('loc', [10,20], [13, 25], [7,15])
|
|
793
|
+
*
|
|
794
|
+
* @param {String|Array} [path]
|
|
795
|
+
* @param {Array|Object} [val]
|
|
796
|
+
* @return {Query} this
|
|
797
|
+
* @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
|
|
798
|
+
* @api public
|
|
799
|
+
*/
|
|
800
|
+
|
|
801
|
+
Query.prototype.polygon = function() {
|
|
802
|
+
let val, path;
|
|
803
|
+
|
|
804
|
+
if ('string' == typeof arguments[0]) {
|
|
805
|
+
// polygon('loc', [],[],[])
|
|
806
|
+
val = Array.from(arguments);
|
|
807
|
+
path = val.shift();
|
|
808
|
+
} else {
|
|
809
|
+
// polygon([],[],[])
|
|
810
|
+
this._ensurePath('polygon');
|
|
811
|
+
path = this._path;
|
|
812
|
+
val = Array.from(arguments);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
816
|
+
conds[this._geoComparison || '$geoWithin'] = { $polygon: val };
|
|
817
|
+
return this;
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Specifies a $center or $centerSphere condition.
|
|
822
|
+
*
|
|
823
|
+
* #### Example:
|
|
824
|
+
*
|
|
825
|
+
* var area = { center: [50, 50], radius: 10, unique: true }
|
|
826
|
+
* query.where('loc').within().circle(area)
|
|
827
|
+
* query.center('loc', area);
|
|
828
|
+
*
|
|
829
|
+
* // for spherical calculations
|
|
830
|
+
* var area = { center: [50, 50], radius: 10, unique: true, spherical: true }
|
|
831
|
+
* query.where('loc').within().circle(area)
|
|
832
|
+
* query.center('loc', area);
|
|
833
|
+
*
|
|
834
|
+
* @param {String} [path]
|
|
835
|
+
* @param {Object} area
|
|
836
|
+
* @return {Query} this
|
|
837
|
+
* @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
|
|
838
|
+
* @api public
|
|
839
|
+
*/
|
|
840
|
+
|
|
841
|
+
Query.prototype.circle = function() {
|
|
842
|
+
let path, val;
|
|
843
|
+
|
|
844
|
+
if (1 === arguments.length) {
|
|
845
|
+
this._ensurePath('circle');
|
|
846
|
+
path = this._path;
|
|
847
|
+
val = arguments[0];
|
|
848
|
+
} else if (2 === arguments.length) {
|
|
849
|
+
path = arguments[0];
|
|
850
|
+
val = arguments[1];
|
|
851
|
+
} else {
|
|
852
|
+
throw new TypeError('Invalid argument');
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
if (!('radius' in val && val.center))
|
|
856
|
+
throw new Error('center and radius are required');
|
|
857
|
+
|
|
858
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
859
|
+
|
|
860
|
+
const type = val.spherical
|
|
861
|
+
? '$centerSphere'
|
|
862
|
+
: '$center';
|
|
863
|
+
|
|
864
|
+
const wKey = this._geoComparison || '$geoWithin';
|
|
865
|
+
conds[wKey] = {};
|
|
866
|
+
conds[wKey][type] = [val.center, val.radius];
|
|
867
|
+
|
|
868
|
+
if ('unique' in val)
|
|
869
|
+
conds[wKey].$uniqueDocs = !!val.unique;
|
|
870
|
+
|
|
871
|
+
return this;
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Specifies a `$near` or `$nearSphere` condition
|
|
876
|
+
*
|
|
877
|
+
* These operators return documents sorted by distance.
|
|
878
|
+
*
|
|
879
|
+
* #### Example:
|
|
880
|
+
*
|
|
881
|
+
* query.where('loc').near({ center: [10, 10] });
|
|
882
|
+
* query.where('loc').near({ center: [10, 10], maxDistance: 5 });
|
|
883
|
+
* query.where('loc').near({ center: [10, 10], maxDistance: 5, spherical: true });
|
|
884
|
+
* query.near('loc', { center: [10, 10], maxDistance: 5 });
|
|
885
|
+
* query.near({ center: { type: 'Point', coordinates: [..] }})
|
|
886
|
+
* query.near().geometry({ type: 'Point', coordinates: [..] })
|
|
887
|
+
*
|
|
888
|
+
* @param {String} [path]
|
|
889
|
+
* @param {Object} val
|
|
890
|
+
* @return {Query} this
|
|
891
|
+
* @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
|
|
892
|
+
* @api public
|
|
893
|
+
*/
|
|
894
|
+
|
|
895
|
+
Query.prototype.near = function near() {
|
|
896
|
+
let path, val;
|
|
897
|
+
|
|
898
|
+
this._geoComparison = '$near';
|
|
899
|
+
|
|
900
|
+
if (0 === arguments.length) {
|
|
901
|
+
return this;
|
|
902
|
+
} else if (1 === arguments.length) {
|
|
903
|
+
this._ensurePath('near');
|
|
904
|
+
path = this._path;
|
|
905
|
+
val = arguments[0];
|
|
906
|
+
} else if (2 === arguments.length) {
|
|
907
|
+
path = arguments[0];
|
|
908
|
+
val = arguments[1];
|
|
909
|
+
} else {
|
|
910
|
+
throw new TypeError('Invalid argument');
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
if (!val.center) {
|
|
914
|
+
throw new Error('center is required');
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
918
|
+
|
|
919
|
+
const type = val.spherical
|
|
920
|
+
? '$nearSphere'
|
|
921
|
+
: '$near';
|
|
922
|
+
|
|
923
|
+
// center could be a GeoJSON object or an Array
|
|
924
|
+
if (Array.isArray(val.center)) {
|
|
925
|
+
conds[type] = val.center;
|
|
926
|
+
|
|
927
|
+
const radius = 'maxDistance' in val
|
|
928
|
+
? val.maxDistance
|
|
929
|
+
: null;
|
|
930
|
+
|
|
931
|
+
if (null != radius) {
|
|
932
|
+
conds.$maxDistance = radius;
|
|
933
|
+
}
|
|
934
|
+
if (null != val.minDistance) {
|
|
935
|
+
conds.$minDistance = val.minDistance;
|
|
936
|
+
}
|
|
937
|
+
} else {
|
|
938
|
+
// GeoJSON?
|
|
939
|
+
if (val.center.type != 'Point' || !Array.isArray(val.center.coordinates)) {
|
|
940
|
+
throw new Error(util.format('Invalid GeoJSON specified for %s', type));
|
|
941
|
+
}
|
|
942
|
+
conds[type] = { $geometry: val.center };
|
|
943
|
+
|
|
944
|
+
// MongoDB 2.6 insists on maxDistance being in $near / $nearSphere
|
|
945
|
+
if ('maxDistance' in val) {
|
|
946
|
+
conds[type]['$maxDistance'] = val.maxDistance;
|
|
947
|
+
}
|
|
948
|
+
if ('minDistance' in val) {
|
|
949
|
+
conds[type]['$minDistance'] = val.minDistance;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
return this;
|
|
954
|
+
};
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Declares an intersects query for `geometry()`.
|
|
958
|
+
*
|
|
959
|
+
* #### Example:
|
|
960
|
+
*
|
|
961
|
+
* query.where('path').intersects().geometry({
|
|
962
|
+
* type: 'LineString'
|
|
963
|
+
* , coordinates: [[180.0, 11.0], [180, 9.0]]
|
|
964
|
+
* })
|
|
965
|
+
*
|
|
966
|
+
* query.where('path').intersects({
|
|
967
|
+
* type: 'LineString'
|
|
968
|
+
* , coordinates: [[180.0, 11.0], [180, 9.0]]
|
|
969
|
+
* })
|
|
970
|
+
*
|
|
971
|
+
* @param {Object} [arg]
|
|
972
|
+
* @return {Query} this
|
|
973
|
+
* @api public
|
|
974
|
+
*/
|
|
975
|
+
|
|
976
|
+
Query.prototype.intersects = function intersects() {
|
|
977
|
+
// opinionated, must be used after where
|
|
978
|
+
this._ensurePath('intersects');
|
|
979
|
+
|
|
980
|
+
this._geoComparison = '$geoIntersects';
|
|
981
|
+
|
|
982
|
+
if (0 === arguments.length) {
|
|
983
|
+
return this;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
const area = arguments[0];
|
|
987
|
+
|
|
988
|
+
if (null != area && area.type && area.coordinates)
|
|
989
|
+
return this.geometry(area);
|
|
990
|
+
|
|
991
|
+
throw new TypeError('Invalid argument');
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* Specifies a `$geometry` condition
|
|
996
|
+
*
|
|
997
|
+
* #### Example:
|
|
998
|
+
*
|
|
999
|
+
* var polyA = [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]]
|
|
1000
|
+
* query.where('loc').within().geometry({ type: 'Polygon', coordinates: polyA })
|
|
1001
|
+
*
|
|
1002
|
+
* // or
|
|
1003
|
+
* var polyB = [[ 0, 0 ], [ 1, 1 ]]
|
|
1004
|
+
* query.where('loc').within().geometry({ type: 'LineString', coordinates: polyB })
|
|
1005
|
+
*
|
|
1006
|
+
* // or
|
|
1007
|
+
* var polyC = [ 0, 0 ]
|
|
1008
|
+
* query.where('loc').within().geometry({ type: 'Point', coordinates: polyC })
|
|
1009
|
+
*
|
|
1010
|
+
* // or
|
|
1011
|
+
* query.where('loc').intersects().geometry({ type: 'Point', coordinates: polyC })
|
|
1012
|
+
*
|
|
1013
|
+
* #### Note:
|
|
1014
|
+
*
|
|
1015
|
+
* `geometry()` **must** come after either `intersects()` or `within()`.
|
|
1016
|
+
*
|
|
1017
|
+
* The `object` argument must contain `type` and `coordinates` properties.
|
|
1018
|
+
* - type {String}
|
|
1019
|
+
* - coordinates {Array}
|
|
1020
|
+
*
|
|
1021
|
+
* The most recent path passed to `where()` is used.
|
|
1022
|
+
*
|
|
1023
|
+
* @param {Object} object Must contain a `type` property which is a String and a `coordinates` property which is an Array. See the examples.
|
|
1024
|
+
* @return {Query} this
|
|
1025
|
+
* @see http://docs.mongodb.org/manual/release-notes/2.4/#new-geospatial-indexes-with-geojson-and-improved-spherical-geometry
|
|
1026
|
+
* @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
|
|
1027
|
+
* @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
|
|
1028
|
+
* @api public
|
|
1029
|
+
*/
|
|
1030
|
+
|
|
1031
|
+
Query.prototype.geometry = function geometry() {
|
|
1032
|
+
if (!('$within' == this._geoComparison ||
|
|
1033
|
+
'$geoWithin' == this._geoComparison ||
|
|
1034
|
+
'$near' == this._geoComparison ||
|
|
1035
|
+
'$geoIntersects' == this._geoComparison)) {
|
|
1036
|
+
throw new Error('geometry() must come after `within()`, `intersects()`, or `near()');
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
let val, path;
|
|
1040
|
+
|
|
1041
|
+
if (1 === arguments.length) {
|
|
1042
|
+
this._ensurePath('geometry');
|
|
1043
|
+
path = this._path;
|
|
1044
|
+
val = arguments[0];
|
|
1045
|
+
} else {
|
|
1046
|
+
throw new TypeError('Invalid argument');
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
if (!(val.type && Array.isArray(val.coordinates))) {
|
|
1050
|
+
throw new TypeError('Invalid argument');
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
const conds = this._conditions[path] || (this._conditions[path] = {});
|
|
1054
|
+
conds[this._geoComparison] = { $geometry: val };
|
|
1055
|
+
|
|
1056
|
+
return this;
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
// end spatial
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* Specifies which document fields to include or exclude
|
|
1063
|
+
*
|
|
1064
|
+
* #### String syntax
|
|
1065
|
+
*
|
|
1066
|
+
* When passing a string, prefixing a path with `-` will flag that path as excluded. When a path does not have the `-` prefix, it is included.
|
|
1067
|
+
*
|
|
1068
|
+
* #### Example:
|
|
1069
|
+
*
|
|
1070
|
+
* // include a and b, exclude c
|
|
1071
|
+
* query.select('a b -c');
|
|
1072
|
+
*
|
|
1073
|
+
* // or you may use object notation, useful when
|
|
1074
|
+
* // you have keys already prefixed with a "-"
|
|
1075
|
+
* query.select({a: 1, b: 1, c: 0});
|
|
1076
|
+
*
|
|
1077
|
+
* #### Note:
|
|
1078
|
+
*
|
|
1079
|
+
* Cannot be used with `distinct()`
|
|
1080
|
+
*
|
|
1081
|
+
* @param {Object|String} arg
|
|
1082
|
+
* @return {Query} this
|
|
1083
|
+
* @see SchemaType
|
|
1084
|
+
* @api public
|
|
1085
|
+
*/
|
|
1086
|
+
|
|
1087
|
+
Query.prototype.select = function select() {
|
|
1088
|
+
let arg = arguments[0];
|
|
1089
|
+
if (!arg) return this;
|
|
1090
|
+
|
|
1091
|
+
if (arguments.length !== 1) {
|
|
1092
|
+
throw new Error('Invalid select: select only takes 1 argument');
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
this._validate('select');
|
|
1096
|
+
|
|
1097
|
+
const fields = this._fields || (this._fields = {});
|
|
1098
|
+
const type = typeof arg;
|
|
1099
|
+
let i, len;
|
|
1100
|
+
|
|
1101
|
+
if (('string' == type || utils.isArgumentsObject(arg)) &&
|
|
1102
|
+
'number' == typeof arg.length || Array.isArray(arg)) {
|
|
1103
|
+
if ('string' == type)
|
|
1104
|
+
arg = arg.split(/\s+/);
|
|
1105
|
+
|
|
1106
|
+
for (i = 0, len = arg.length; i < len; ++i) {
|
|
1107
|
+
let field = arg[i];
|
|
1108
|
+
if (!field) continue;
|
|
1109
|
+
const include = '-' == field[0] ? 0 : 1;
|
|
1110
|
+
if (include === 0) field = field.substring(1);
|
|
1111
|
+
fields[field] = include;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
return this;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
if (utils.isObject(arg)) {
|
|
1118
|
+
const keys = utils.keys(arg);
|
|
1119
|
+
for (i = 0; i < keys.length; ++i) {
|
|
1120
|
+
fields[keys[i]] = arg[keys[i]];
|
|
1121
|
+
}
|
|
1122
|
+
return this;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
throw new TypeError('Invalid select() argument. Must be string or object.');
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Specifies a $slice condition for a `path`
|
|
1130
|
+
*
|
|
1131
|
+
* #### Example:
|
|
1132
|
+
*
|
|
1133
|
+
* query.slice('comments', 5)
|
|
1134
|
+
* query.slice('comments', -5)
|
|
1135
|
+
* query.slice('comments', [10, 5])
|
|
1136
|
+
* query.where('comments').slice(5)
|
|
1137
|
+
* query.where('comments').slice([-10, 5])
|
|
1138
|
+
*
|
|
1139
|
+
* @param {String} [path]
|
|
1140
|
+
* @param {Number} val number/range of elements to slice
|
|
1141
|
+
* @return {Query} this
|
|
1142
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements
|
|
1143
|
+
* @api public
|
|
1144
|
+
*/
|
|
1145
|
+
|
|
1146
|
+
Query.prototype.slice = function() {
|
|
1147
|
+
if (0 === arguments.length)
|
|
1148
|
+
return this;
|
|
1149
|
+
|
|
1150
|
+
this._validate('slice');
|
|
1151
|
+
|
|
1152
|
+
let path, val;
|
|
1153
|
+
|
|
1154
|
+
if (1 === arguments.length) {
|
|
1155
|
+
const arg = arguments[0];
|
|
1156
|
+
if (typeof arg === 'object' && !Array.isArray(arg)) {
|
|
1157
|
+
const keys = Object.keys(arg);
|
|
1158
|
+
const numKeys = keys.length;
|
|
1159
|
+
for (let i = 0; i < numKeys; ++i) {
|
|
1160
|
+
this.slice(keys[i], arg[keys[i]]);
|
|
1161
|
+
}
|
|
1162
|
+
return this;
|
|
1163
|
+
}
|
|
1164
|
+
this._ensurePath('slice');
|
|
1165
|
+
path = this._path;
|
|
1166
|
+
val = arguments[0];
|
|
1167
|
+
} else if (2 === arguments.length) {
|
|
1168
|
+
if ('number' === typeof arguments[0]) {
|
|
1169
|
+
this._ensurePath('slice');
|
|
1170
|
+
path = this._path;
|
|
1171
|
+
val = [arguments[0], arguments[1]];
|
|
1172
|
+
} else {
|
|
1173
|
+
path = arguments[0];
|
|
1174
|
+
val = arguments[1];
|
|
1175
|
+
}
|
|
1176
|
+
} else if (3 === arguments.length) {
|
|
1177
|
+
path = arguments[0];
|
|
1178
|
+
val = [arguments[1], arguments[2]];
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
const myFields = this._fields || (this._fields = {});
|
|
1182
|
+
myFields[path] = { $slice: val };
|
|
1183
|
+
return this;
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* Sets the sort order
|
|
1188
|
+
*
|
|
1189
|
+
* If an object is passed, values allowed are 'asc', 'desc', 'ascending', 'descending', 1, and -1.
|
|
1190
|
+
*
|
|
1191
|
+
* If a string is passed, it must be a space delimited list of path names. The sort order of each path is ascending unless the path name is prefixed with `-` which will be treated as descending.
|
|
1192
|
+
*
|
|
1193
|
+
* #### Example:
|
|
1194
|
+
*
|
|
1195
|
+
* // these are equivalent
|
|
1196
|
+
* query.sort({ field: 'asc', test: -1 });
|
|
1197
|
+
* query.sort('field -test');
|
|
1198
|
+
* query.sort([['field', 1], ['test', -1]]);
|
|
1199
|
+
*
|
|
1200
|
+
* #### Note:
|
|
1201
|
+
*
|
|
1202
|
+
* - The array syntax `.sort([['field', 1], ['test', -1]])` can only be used with [mongodb driver >= 2.0.46](https://github.com/mongodb/node-mongodb-native/blob/2.1/HISTORY.md#2046-2015-10-15).
|
|
1203
|
+
* - Cannot be used with `distinct()`
|
|
1204
|
+
*
|
|
1205
|
+
* @param {Object|String|Array} arg
|
|
1206
|
+
* @return {Query} this
|
|
1207
|
+
* @api public
|
|
1208
|
+
*/
|
|
1209
|
+
|
|
1210
|
+
Query.prototype.sort = function(arg) {
|
|
1211
|
+
if (!arg) return this;
|
|
1212
|
+
let i, len, field;
|
|
1213
|
+
|
|
1214
|
+
this._validate('sort');
|
|
1215
|
+
|
|
1216
|
+
const type = typeof arg;
|
|
1217
|
+
|
|
1218
|
+
// .sort([['field', 1], ['test', -1]])
|
|
1219
|
+
if (Array.isArray(arg)) {
|
|
1220
|
+
len = arg.length;
|
|
1221
|
+
for (i = 0; i < arg.length; ++i) {
|
|
1222
|
+
if (!Array.isArray(arg[i])) {
|
|
1223
|
+
throw new Error('Invalid sort() argument, must be array of arrays');
|
|
1224
|
+
}
|
|
1225
|
+
_pushArr(this.options, arg[i][0], arg[i][1]);
|
|
1226
|
+
}
|
|
1227
|
+
return this;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// .sort('field -test')
|
|
1231
|
+
if (1 === arguments.length && 'string' == type) {
|
|
1232
|
+
arg = arg.split(/\s+/);
|
|
1233
|
+
len = arg.length;
|
|
1234
|
+
for (i = 0; i < len; ++i) {
|
|
1235
|
+
field = arg[i];
|
|
1236
|
+
if (!field) continue;
|
|
1237
|
+
const ascend = '-' == field[0] ? -1 : 1;
|
|
1238
|
+
if (ascend === -1) field = field.substring(1);
|
|
1239
|
+
push(this.options, field, ascend);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
return this;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// .sort({ field: 1, test: -1 })
|
|
1246
|
+
if (utils.isObject(arg)) {
|
|
1247
|
+
const keys = utils.keys(arg);
|
|
1248
|
+
for (i = 0; i < keys.length; ++i) {
|
|
1249
|
+
field = keys[i];
|
|
1250
|
+
push(this.options, field, arg[field]);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
return this;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
if (typeof Map !== 'undefined' && arg instanceof Map) {
|
|
1257
|
+
_pushMap(this.options, arg);
|
|
1258
|
+
return this;
|
|
1259
|
+
}
|
|
1260
|
+
throw new TypeError('Invalid sort() argument. Must be a string, object, or array.');
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
/*!
|
|
1264
|
+
* @ignore
|
|
1265
|
+
*/
|
|
1266
|
+
|
|
1267
|
+
const _validSortValue = {
|
|
1268
|
+
1: 1,
|
|
1269
|
+
'-1': -1,
|
|
1270
|
+
asc: 1,
|
|
1271
|
+
ascending: 1,
|
|
1272
|
+
desc: -1,
|
|
1273
|
+
descending: -1
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
function push(opts, field, value) {
|
|
1277
|
+
if (Array.isArray(opts.sort)) {
|
|
1278
|
+
throw new TypeError('Can\'t mix sort syntaxes. Use either array or object:' +
|
|
1279
|
+
'\n- `.sort([[\'field\', 1], [\'test\', -1]])`' +
|
|
1280
|
+
'\n- `.sort({ field: 1, test: -1 })`');
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
let s;
|
|
1284
|
+
if (value && value.$meta) {
|
|
1285
|
+
s = opts.sort || (opts.sort = {});
|
|
1286
|
+
s[field] = { $meta: value.$meta };
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
s = opts.sort || (opts.sort = {});
|
|
1291
|
+
let val = String(value || 1).toLowerCase();
|
|
1292
|
+
val = _validSortValue[val];
|
|
1293
|
+
if (!val) throw new TypeError('Invalid sort value: { ' + field + ': ' + value + ' }');
|
|
1294
|
+
|
|
1295
|
+
s[field] = val;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
function _pushArr(opts, field, value) {
|
|
1299
|
+
opts.sort = opts.sort || [];
|
|
1300
|
+
if (!Array.isArray(opts.sort)) {
|
|
1301
|
+
throw new TypeError('Can\'t mix sort syntaxes. Use either array or object:' +
|
|
1302
|
+
'\n- `.sort([[\'field\', 1], [\'test\', -1]])`' +
|
|
1303
|
+
'\n- `.sort({ field: 1, test: -1 })`');
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
let val = String(value || 1).toLowerCase();
|
|
1307
|
+
val = _validSortValue[val];
|
|
1308
|
+
if (!val) throw new TypeError('Invalid sort value: [ ' + field + ', ' + value + ' ]');
|
|
1309
|
+
|
|
1310
|
+
opts.sort.push([field, val]);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
function _pushMap(opts, map) {
|
|
1314
|
+
opts.sort = opts.sort || new Map();
|
|
1315
|
+
if (!(opts.sort instanceof Map)) {
|
|
1316
|
+
throw new TypeError('Can\'t mix sort syntaxes. Use either array or ' +
|
|
1317
|
+
'object or map consistently');
|
|
1318
|
+
}
|
|
1319
|
+
map.forEach(function(value, key) {
|
|
1320
|
+
let val = String(value || 1).toLowerCase();
|
|
1321
|
+
val = _validSortValue[val];
|
|
1322
|
+
if (!val) throw new TypeError('Invalid sort value: < ' + key + ': ' + value + ' >');
|
|
1323
|
+
|
|
1324
|
+
opts.sort.set(key, val);
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* Specifies the limit option.
|
|
1331
|
+
*
|
|
1332
|
+
* #### Example:
|
|
1333
|
+
*
|
|
1334
|
+
* query.limit(20)
|
|
1335
|
+
*
|
|
1336
|
+
* #### Note:
|
|
1337
|
+
*
|
|
1338
|
+
* Cannot be used with `distinct()`
|
|
1339
|
+
*
|
|
1340
|
+
* @method limit
|
|
1341
|
+
* @memberOf Query
|
|
1342
|
+
* @param {Number} val
|
|
1343
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D
|
|
1344
|
+
* @api public
|
|
1345
|
+
*/
|
|
1346
|
+
/**
|
|
1347
|
+
* Specifies the skip option.
|
|
1348
|
+
*
|
|
1349
|
+
* #### Example:
|
|
1350
|
+
*
|
|
1351
|
+
* query.skip(100).limit(20)
|
|
1352
|
+
*
|
|
1353
|
+
* #### Note:
|
|
1354
|
+
*
|
|
1355
|
+
* Cannot be used with `distinct()`
|
|
1356
|
+
*
|
|
1357
|
+
* @method skip
|
|
1358
|
+
* @memberOf Query
|
|
1359
|
+
* @param {Number} val
|
|
1360
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D
|
|
1361
|
+
* @api public
|
|
1362
|
+
*/
|
|
1363
|
+
/**
|
|
1364
|
+
* Specifies the batchSize option.
|
|
1365
|
+
*
|
|
1366
|
+
* #### Example:
|
|
1367
|
+
*
|
|
1368
|
+
* query.batchSize(100)
|
|
1369
|
+
*
|
|
1370
|
+
* #### Note:
|
|
1371
|
+
*
|
|
1372
|
+
* Cannot be used with `distinct()`
|
|
1373
|
+
*
|
|
1374
|
+
* @method batchSize
|
|
1375
|
+
* @memberOf Query
|
|
1376
|
+
* @param {Number} val
|
|
1377
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D
|
|
1378
|
+
* @api public
|
|
1379
|
+
*/
|
|
1380
|
+
/**
|
|
1381
|
+
* Specifies the `comment` option.
|
|
1382
|
+
*
|
|
1383
|
+
* #### Example:
|
|
1384
|
+
*
|
|
1385
|
+
* query.comment('login query')
|
|
1386
|
+
*
|
|
1387
|
+
* #### Note:
|
|
1388
|
+
*
|
|
1389
|
+
* Cannot be used with `distinct()`
|
|
1390
|
+
*
|
|
1391
|
+
* @method comment
|
|
1392
|
+
* @memberOf Query
|
|
1393
|
+
* @param {Number} val
|
|
1394
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment
|
|
1395
|
+
* @api public
|
|
1396
|
+
*/
|
|
1397
|
+
|
|
1398
|
+
/*!
|
|
1399
|
+
* limit, skip, batchSize, comment
|
|
1400
|
+
*
|
|
1401
|
+
* Sets these associated options.
|
|
1402
|
+
*
|
|
1403
|
+
* query.comment('feed query');
|
|
1404
|
+
*/
|
|
1405
|
+
|
|
1406
|
+
['limit', 'skip', 'batchSize', 'comment'].forEach(function(method) {
|
|
1407
|
+
Query.prototype[method] = function(v) {
|
|
1408
|
+
this._validate(method);
|
|
1409
|
+
this.options[method] = v;
|
|
1410
|
+
return this;
|
|
1411
|
+
};
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* Specifies the maxTimeMS option.
|
|
1416
|
+
*
|
|
1417
|
+
* #### Example:
|
|
1418
|
+
*
|
|
1419
|
+
* query.maxTime(100)
|
|
1420
|
+
* query.maxTimeMS(100)
|
|
1421
|
+
*
|
|
1422
|
+
* @method maxTime
|
|
1423
|
+
* @memberOf Query
|
|
1424
|
+
* @param {Number} ms
|
|
1425
|
+
* @see mongodb http://docs.mongodb.org/manual/reference/operator/meta/maxTimeMS/#op._S_maxTimeMS
|
|
1426
|
+
* @api public
|
|
1427
|
+
*/
|
|
1428
|
+
|
|
1429
|
+
Query.prototype.maxTime = Query.prototype.maxTimeMS = function(ms) {
|
|
1430
|
+
this._validate('maxTime');
|
|
1431
|
+
this.options.maxTimeMS = ms;
|
|
1432
|
+
return this;
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Sets query hints.
|
|
1437
|
+
*
|
|
1438
|
+
* #### Example:
|
|
1439
|
+
*
|
|
1440
|
+
* query.hint({ indexA: 1, indexB: -1});
|
|
1441
|
+
* query.hint('indexA_1_indexB_1');
|
|
1442
|
+
*
|
|
1443
|
+
* #### Note:
|
|
1444
|
+
*
|
|
1445
|
+
* Cannot be used with `distinct()`
|
|
1446
|
+
*
|
|
1447
|
+
* @param {Object|string} val a hint object or the index name
|
|
1448
|
+
* @return {Query} this
|
|
1449
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint
|
|
1450
|
+
* @api public
|
|
1451
|
+
*/
|
|
1452
|
+
|
|
1453
|
+
Query.prototype.hint = function() {
|
|
1454
|
+
if (0 === arguments.length) return this;
|
|
1455
|
+
|
|
1456
|
+
this._validate('hint');
|
|
1457
|
+
|
|
1458
|
+
const arg = arguments[0];
|
|
1459
|
+
if (utils.isObject(arg)) {
|
|
1460
|
+
const hint = this.options.hint || (this.options.hint = {});
|
|
1461
|
+
|
|
1462
|
+
// must keep object keys in order so don't use Object.keys()
|
|
1463
|
+
for (const k in arg) {
|
|
1464
|
+
hint[k] = arg[k];
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
return this;
|
|
1468
|
+
}
|
|
1469
|
+
if (typeof arg === 'string') {
|
|
1470
|
+
this.options.hint = arg;
|
|
1471
|
+
return this;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
throw new TypeError('Invalid hint. ' + arg);
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* Requests acknowledgement that this operation has been persisted to MongoDB's
|
|
1479
|
+
* on-disk journal.
|
|
1480
|
+
* This option is only valid for operations that write to the database:
|
|
1481
|
+
*
|
|
1482
|
+
* - `deleteOne()`
|
|
1483
|
+
* - `deleteMany()`
|
|
1484
|
+
* - `findOneAndDelete()`
|
|
1485
|
+
* - `findOneAndUpdate()`
|
|
1486
|
+
* - `updateOne()`
|
|
1487
|
+
* - `updateMany()`
|
|
1488
|
+
*
|
|
1489
|
+
* Defaults to the `j` value if it is specified in writeConcern options
|
|
1490
|
+
*
|
|
1491
|
+
* #### Example:
|
|
1492
|
+
*
|
|
1493
|
+
* mquery().w(2).j(true).wtimeout(2000);
|
|
1494
|
+
*
|
|
1495
|
+
* @method j
|
|
1496
|
+
* @memberOf Query
|
|
1497
|
+
* @instance
|
|
1498
|
+
* @param {boolean} val
|
|
1499
|
+
* @see mongodb https://docs.mongodb.com/manual/reference/write-concern/#j-option
|
|
1500
|
+
* @return {Query} this
|
|
1501
|
+
* @api public
|
|
1502
|
+
*/
|
|
1503
|
+
|
|
1504
|
+
Query.prototype.j = function j(val) {
|
|
1505
|
+
this.options.j = val;
|
|
1506
|
+
return this;
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* Sets the slaveOk option. _Deprecated_ in MongoDB 2.2 in favor of read preferences.
|
|
1511
|
+
*
|
|
1512
|
+
* #### Example:
|
|
1513
|
+
*
|
|
1514
|
+
* query.slaveOk() // true
|
|
1515
|
+
* query.slaveOk(true)
|
|
1516
|
+
* query.slaveOk(false)
|
|
1517
|
+
*
|
|
1518
|
+
* @deprecated use read() preferences instead if on mongodb >= 2.2
|
|
1519
|
+
* @param {Boolean} v defaults to true
|
|
1520
|
+
* @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
|
|
1521
|
+
* @see read()
|
|
1522
|
+
* @return {Query} this
|
|
1523
|
+
* @api public
|
|
1524
|
+
*/
|
|
1525
|
+
|
|
1526
|
+
Query.prototype.slaveOk = function(v) {
|
|
1527
|
+
this.options.slaveOk = arguments.length ? !!v : true;
|
|
1528
|
+
return this;
|
|
1529
|
+
};
|
|
1530
|
+
|
|
1531
|
+
/**
|
|
1532
|
+
* Sets the readPreference option for the query.
|
|
1533
|
+
*
|
|
1534
|
+
* #### Example:
|
|
1535
|
+
*
|
|
1536
|
+
* new Query().read('primary')
|
|
1537
|
+
* new Query().read('p') // same as primary
|
|
1538
|
+
*
|
|
1539
|
+
* new Query().read('primaryPreferred')
|
|
1540
|
+
* new Query().read('pp') // same as primaryPreferred
|
|
1541
|
+
*
|
|
1542
|
+
* new Query().read('secondary')
|
|
1543
|
+
* new Query().read('s') // same as secondary
|
|
1544
|
+
*
|
|
1545
|
+
* new Query().read('secondaryPreferred')
|
|
1546
|
+
* new Query().read('sp') // same as secondaryPreferred
|
|
1547
|
+
*
|
|
1548
|
+
* new Query().read('nearest')
|
|
1549
|
+
* new Query().read('n') // same as nearest
|
|
1550
|
+
*
|
|
1551
|
+
* // you can also use mongodb.ReadPreference class to also specify tags
|
|
1552
|
+
* new Query().read(mongodb.ReadPreference('secondary', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }]))
|
|
1553
|
+
*
|
|
1554
|
+
* new Query().setReadPreference('primary') // alias of .read()
|
|
1555
|
+
*
|
|
1556
|
+
* #### Preferences:
|
|
1557
|
+
*
|
|
1558
|
+
* primary - (default) Read from primary only. Operations will produce an error if primary is unavailable. Cannot be combined with tags.
|
|
1559
|
+
* secondary Read from secondary if available, otherwise error.
|
|
1560
|
+
* primaryPreferred Read from primary if available, otherwise a secondary.
|
|
1561
|
+
* secondaryPreferred Read from a secondary if available, otherwise read from the primary.
|
|
1562
|
+
* nearest All operations read from among the nearest candidates, but unlike other modes, this option will include both the primary and all secondaries in the random selection.
|
|
1563
|
+
*
|
|
1564
|
+
* Aliases
|
|
1565
|
+
*
|
|
1566
|
+
* p primary
|
|
1567
|
+
* pp primaryPreferred
|
|
1568
|
+
* s secondary
|
|
1569
|
+
* sp secondaryPreferred
|
|
1570
|
+
* n nearest
|
|
1571
|
+
*
|
|
1572
|
+
* Read more about how to use read preferences [here](http://docs.mongodb.org/manual/applications/replication/#read-preference) and [here](http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences).
|
|
1573
|
+
*
|
|
1574
|
+
* @param {String|ReadPreference} pref one of the listed preference options or their aliases
|
|
1575
|
+
* @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
|
|
1576
|
+
* @see driver http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences
|
|
1577
|
+
* @return {Query} this
|
|
1578
|
+
* @api public
|
|
1579
|
+
*/
|
|
1580
|
+
|
|
1581
|
+
Query.prototype.read = Query.prototype.setReadPreference = function(pref) {
|
|
1582
|
+
if (arguments.length > 1 && !Query.prototype.read.deprecationWarningIssued) {
|
|
1583
|
+
console.error('Deprecation warning: \'tags\' argument is not supported anymore in Query.read() method. Please use mongodb.ReadPreference object instead.');
|
|
1584
|
+
Query.prototype.read.deprecationWarningIssued = true;
|
|
1585
|
+
}
|
|
1586
|
+
this.options.readPreference = utils.readPref(pref);
|
|
1587
|
+
return this;
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Sets the readConcern option for the query.
|
|
1592
|
+
*
|
|
1593
|
+
* #### Example:
|
|
1594
|
+
*
|
|
1595
|
+
* new Query().readConcern('local')
|
|
1596
|
+
* new Query().readConcern('l') // same as local
|
|
1597
|
+
*
|
|
1598
|
+
* new Query().readConcern('available')
|
|
1599
|
+
* new Query().readConcern('a') // same as available
|
|
1600
|
+
*
|
|
1601
|
+
* new Query().readConcern('majority')
|
|
1602
|
+
* new Query().readConcern('m') // same as majority
|
|
1603
|
+
*
|
|
1604
|
+
* new Query().readConcern('linearizable')
|
|
1605
|
+
* new Query().readConcern('lz') // same as linearizable
|
|
1606
|
+
*
|
|
1607
|
+
* new Query().readConcern('snapshot')
|
|
1608
|
+
* new Query().readConcern('s') // same as snapshot
|
|
1609
|
+
*
|
|
1610
|
+
* new Query().r('s') // r is alias of readConcern
|
|
1611
|
+
*
|
|
1612
|
+
*
|
|
1613
|
+
* #### Read Concern Level:
|
|
1614
|
+
*
|
|
1615
|
+
* local MongoDB 3.2+ The query returns from the instance with no guarantee guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back).
|
|
1616
|
+
* available MongoDB 3.6+ The query returns from the instance with no guarantee guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back).
|
|
1617
|
+
* majority MongoDB 3.2+ The query returns the data that has been acknowledged by a majority of the replica set members. The documents returned by the read operation are durable, even in the event of failure.
|
|
1618
|
+
* linearizable MongoDB 3.4+ The query returns data that reflects all successful majority-acknowledged writes that completed prior to the start of the read operation. The query may wait for concurrently executing writes to propagate to a majority of replica set members before returning results.
|
|
1619
|
+
* snapshot MongoDB 4.0+ Only available for operations within multi-document transactions. Upon transaction commit with write concern "majority", the transaction operations are guaranteed to have read from a snapshot of majority-committed data.
|
|
1620
|
+
*
|
|
1621
|
+
* Aliases
|
|
1622
|
+
*
|
|
1623
|
+
* l local
|
|
1624
|
+
* a available
|
|
1625
|
+
* m majority
|
|
1626
|
+
* lz linearizable
|
|
1627
|
+
* s snapshot
|
|
1628
|
+
*
|
|
1629
|
+
* Read more about how to use read concern [here](https://docs.mongodb.com/manual/reference/read-concern/).
|
|
1630
|
+
*
|
|
1631
|
+
* @param {String} level one of the listed read concern level or their aliases
|
|
1632
|
+
* @see mongodb https://docs.mongodb.com/manual/reference/read-concern/
|
|
1633
|
+
* @return {Query} this
|
|
1634
|
+
* @api public
|
|
1635
|
+
*/
|
|
1636
|
+
|
|
1637
|
+
Query.prototype.readConcern = Query.prototype.r = function(level) {
|
|
1638
|
+
this.options.readConcern = utils.readConcern(level);
|
|
1639
|
+
return this;
|
|
1640
|
+
};
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* Sets tailable option.
|
|
1644
|
+
*
|
|
1645
|
+
* #### Example:
|
|
1646
|
+
*
|
|
1647
|
+
* query.tailable() <== true
|
|
1648
|
+
* query.tailable(true)
|
|
1649
|
+
* query.tailable(false)
|
|
1650
|
+
*
|
|
1651
|
+
* #### Note:
|
|
1652
|
+
*
|
|
1653
|
+
* Cannot be used with `distinct()`
|
|
1654
|
+
*
|
|
1655
|
+
* @param {Boolean} v defaults to true
|
|
1656
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Tailable+Cursors
|
|
1657
|
+
* @api public
|
|
1658
|
+
*/
|
|
1659
|
+
|
|
1660
|
+
Query.prototype.tailable = function() {
|
|
1661
|
+
this._validate('tailable');
|
|
1662
|
+
|
|
1663
|
+
this.options.tailable = arguments.length
|
|
1664
|
+
? !!arguments[0]
|
|
1665
|
+
: true;
|
|
1666
|
+
|
|
1667
|
+
return this;
|
|
1668
|
+
};
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* Sets the specified number of `mongod` servers, or tag set of `mongod` servers,
|
|
1672
|
+
* that must acknowledge this write before this write is considered successful.
|
|
1673
|
+
* This option is only valid for operations that write to the database:
|
|
1674
|
+
*
|
|
1675
|
+
* - `deleteOne()`
|
|
1676
|
+
* - `deleteMany()`
|
|
1677
|
+
* - `findOneAndDelete()`
|
|
1678
|
+
* - `findOneAndUpdate()`
|
|
1679
|
+
* - `updateOne()`
|
|
1680
|
+
* - `updateMany()`
|
|
1681
|
+
*
|
|
1682
|
+
* Defaults to the `w` value if it is specified in writeConcern options
|
|
1683
|
+
*
|
|
1684
|
+
* #### Example:
|
|
1685
|
+
*
|
|
1686
|
+
* mquery().writeConcern(0)
|
|
1687
|
+
* mquery().writeConcern(1)
|
|
1688
|
+
* mquery().writeConcern({ w: 1, j: true, wtimeout: 2000 })
|
|
1689
|
+
* mquery().writeConcern('majority')
|
|
1690
|
+
* mquery().writeConcern('m') // same as majority
|
|
1691
|
+
* mquery().writeConcern('tagSetName') // if the tag set is 'm', use .writeConcern({ w: 'm' }) instead
|
|
1692
|
+
* mquery().w(1) // w is alias of writeConcern
|
|
1693
|
+
*
|
|
1694
|
+
* @method writeConcern
|
|
1695
|
+
* @memberOf Query
|
|
1696
|
+
* @instance
|
|
1697
|
+
* @param {String|number|object} concern 0 for fire-and-forget, 1 for acknowledged by one server, 'majority' for majority of the replica set, or [any of the more advanced options](https://docs.mongodb.com/manual/reference/write-concern/#w-option).
|
|
1698
|
+
* @see mongodb https://docs.mongodb.com/manual/reference/write-concern/#w-option
|
|
1699
|
+
* @return {Query} this
|
|
1700
|
+
* @api public
|
|
1701
|
+
*/
|
|
1702
|
+
|
|
1703
|
+
Query.prototype.writeConcern = Query.prototype.w = function writeConcern(concern) {
|
|
1704
|
+
if ('object' === typeof concern) {
|
|
1705
|
+
if ('undefined' !== typeof concern.j) this.options.j = concern.j;
|
|
1706
|
+
if ('undefined' !== typeof concern.w) this.options.w = concern.w;
|
|
1707
|
+
if ('undefined' !== typeof concern.wtimeout) this.options.wtimeout = concern.wtimeout;
|
|
1708
|
+
} else {
|
|
1709
|
+
this.options.w = 'm' === concern ? 'majority' : concern;
|
|
1710
|
+
}
|
|
1711
|
+
return this;
|
|
1712
|
+
};
|
|
1713
|
+
|
|
1714
|
+
/**
|
|
1715
|
+
* Specifies a time limit, in milliseconds, for the write concern.
|
|
1716
|
+
* If `ms > 1`, it is maximum amount of time to wait for this write
|
|
1717
|
+
* to propagate through the replica set before this operation fails.
|
|
1718
|
+
* The default is `0`, which means no timeout.
|
|
1719
|
+
*
|
|
1720
|
+
* This option is only valid for operations that write to the database:
|
|
1721
|
+
*
|
|
1722
|
+
* - `deleteOne()`
|
|
1723
|
+
* - `deleteMany()`
|
|
1724
|
+
* - `findOneAndDelete()`
|
|
1725
|
+
* - `findOneAndUpdate()`
|
|
1726
|
+
* - `updateOne()`
|
|
1727
|
+
* - `updateMany()`
|
|
1728
|
+
*
|
|
1729
|
+
* Defaults to `wtimeout` value if it is specified in writeConcern
|
|
1730
|
+
*
|
|
1731
|
+
* #### Example:
|
|
1732
|
+
*
|
|
1733
|
+
* mquery().w(2).j(true).wtimeout(2000)
|
|
1734
|
+
*
|
|
1735
|
+
* @method wtimeout
|
|
1736
|
+
* @memberOf Query
|
|
1737
|
+
* @instance
|
|
1738
|
+
* @param {number} ms number of milliseconds to wait
|
|
1739
|
+
* @see mongodb https://docs.mongodb.com/manual/reference/write-concern/#wtimeout
|
|
1740
|
+
* @return {Query} this
|
|
1741
|
+
* @api public
|
|
1742
|
+
*/
|
|
1743
|
+
|
|
1744
|
+
Query.prototype.wtimeout = Query.prototype.wTimeout = function wtimeout(ms) {
|
|
1745
|
+
this.options.wtimeout = ms;
|
|
1746
|
+
return this;
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* Merges another Query or conditions object into this one.
|
|
1751
|
+
*
|
|
1752
|
+
* When a Query is passed, conditions, field selection and options are merged.
|
|
1753
|
+
*
|
|
1754
|
+
* @param {Query|Object} source
|
|
1755
|
+
* @return {Query} this
|
|
1756
|
+
*/
|
|
1757
|
+
|
|
1758
|
+
Query.prototype.merge = function(source) {
|
|
1759
|
+
if (!source)
|
|
1760
|
+
return this;
|
|
1761
|
+
|
|
1762
|
+
if (!Query.canMerge(source))
|
|
1763
|
+
throw new TypeError('Invalid argument. Expected instanceof mquery or plain object');
|
|
1764
|
+
|
|
1765
|
+
if (source instanceof Query) {
|
|
1766
|
+
// if source has a feature, apply it to ourselves
|
|
1767
|
+
|
|
1768
|
+
if (source._conditions) {
|
|
1769
|
+
utils.merge(this._conditions, source._conditions);
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
if (source._fields) {
|
|
1773
|
+
this._fields || (this._fields = {});
|
|
1774
|
+
utils.merge(this._fields, source._fields);
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
if (source.options) {
|
|
1778
|
+
this.options || (this.options = {});
|
|
1779
|
+
utils.merge(this.options, source.options);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
if (source._updateDoc) {
|
|
1783
|
+
this._updateDoc || (this._updateDoc = {});
|
|
1784
|
+
utils.mergeClone(this._updateDoc, source._updateDoc);
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
if (source._distinctDoc) {
|
|
1788
|
+
this._distinctDoc = source._distinctDoc;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
return this;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
// plain object
|
|
1795
|
+
utils.merge(this._conditions, source);
|
|
1796
|
+
|
|
1797
|
+
return this;
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
/**
|
|
1801
|
+
* Finds documents.
|
|
1802
|
+
*
|
|
1803
|
+
* #### Example:
|
|
1804
|
+
*
|
|
1805
|
+
* query.find()
|
|
1806
|
+
* await query.find()
|
|
1807
|
+
* await query.find({ name: 'Burning Lights' })
|
|
1808
|
+
*
|
|
1809
|
+
* @param {Object} [criteria] mongodb selector
|
|
1810
|
+
* @return {Query} this
|
|
1811
|
+
* @api public
|
|
1812
|
+
*/
|
|
1813
|
+
|
|
1814
|
+
Query.prototype.find = function(criteria) {
|
|
1815
|
+
this.op = 'find';
|
|
1816
|
+
|
|
1817
|
+
if (Query.canMerge(criteria)) {
|
|
1818
|
+
this.merge(criteria);
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
return this;
|
|
1822
|
+
};
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* Executes a `find` Query
|
|
1826
|
+
* @returns the result
|
|
1827
|
+
*/
|
|
1828
|
+
Query.prototype._find = async function _find() {
|
|
1829
|
+
const conds = this._conditions;
|
|
1830
|
+
const options = this._optionsForExec();
|
|
1831
|
+
|
|
1832
|
+
if (this.$useProjection) {
|
|
1833
|
+
options.projection = this._fieldsForExec();
|
|
1834
|
+
} else {
|
|
1835
|
+
options.fields = this._fieldsForExec();
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
debug('find', this._collection.collectionName, conds, options);
|
|
1839
|
+
|
|
1840
|
+
return this._collection.find(conds, options);
|
|
1841
|
+
};
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* Returns the query cursor
|
|
1845
|
+
*
|
|
1846
|
+
* #### Examples:
|
|
1847
|
+
*
|
|
1848
|
+
* query.find().cursor();
|
|
1849
|
+
* query.cursor({ name: 'Burning Lights' });
|
|
1850
|
+
*
|
|
1851
|
+
* @param {Object} [criteria] mongodb selector
|
|
1852
|
+
* @return {Object} cursor
|
|
1853
|
+
* @api public
|
|
1854
|
+
*/
|
|
1855
|
+
|
|
1856
|
+
Query.prototype.cursor = function cursor(criteria) {
|
|
1857
|
+
if (this.op) {
|
|
1858
|
+
if (this.op !== 'find') {
|
|
1859
|
+
throw new TypeError('.cursor only support .find method');
|
|
1860
|
+
}
|
|
1861
|
+
} else {
|
|
1862
|
+
this.find(criteria);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
const conds = this._conditions;
|
|
1866
|
+
const options = this._optionsForExec();
|
|
1867
|
+
|
|
1868
|
+
if (this.$useProjection) {
|
|
1869
|
+
options.projection = this._fieldsForExec();
|
|
1870
|
+
} else {
|
|
1871
|
+
options.fields = this._fieldsForExec();
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
debug('findCursor', this._collection.collectionName, conds, options);
|
|
1875
|
+
|
|
1876
|
+
return this._collection.findCursor(conds, options);
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Executes the query as a findOne() operation.
|
|
1881
|
+
*
|
|
1882
|
+
* #### Example:
|
|
1883
|
+
*
|
|
1884
|
+
* query.findOne().where('name', /^Burning/);
|
|
1885
|
+
*
|
|
1886
|
+
* query.findOne({ name: /^Burning/ })
|
|
1887
|
+
*
|
|
1888
|
+
* await query.findOne({ name: /^Burning/ }); // executes
|
|
1889
|
+
*
|
|
1890
|
+
* @param {Object|Query} [criteria] mongodb selector
|
|
1891
|
+
* @return {Query} this
|
|
1892
|
+
* @api public
|
|
1893
|
+
*/
|
|
1894
|
+
|
|
1895
|
+
Query.prototype.findOne = function(criteria) {
|
|
1896
|
+
this.op = 'findOne';
|
|
1897
|
+
|
|
1898
|
+
if (Query.canMerge(criteria)) {
|
|
1899
|
+
this.merge(criteria);
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
return this;
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* Executes a `findOne` Query
|
|
1907
|
+
* @returns the results
|
|
1908
|
+
*/
|
|
1909
|
+
Query.prototype._findOne = async function _findOne() {
|
|
1910
|
+
const conds = this._conditions;
|
|
1911
|
+
const options = this._optionsForExec();
|
|
1912
|
+
|
|
1913
|
+
if (this.$useProjection) {
|
|
1914
|
+
options.projection = this._fieldsForExec();
|
|
1915
|
+
} else {
|
|
1916
|
+
options.fields = this._fieldsForExec();
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
debug('findOne', this._collection.collectionName, conds, options);
|
|
1920
|
+
|
|
1921
|
+
return this._collection.findOne(conds, options);
|
|
1922
|
+
};
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Executes the query as a countDocuments() operation.
|
|
1926
|
+
*
|
|
1927
|
+
* #### Example:
|
|
1928
|
+
*
|
|
1929
|
+
* query.countDocuments().where('color', 'black').exec();
|
|
1930
|
+
*
|
|
1931
|
+
* query.countDocuments({ color: 'black' })
|
|
1932
|
+
*
|
|
1933
|
+
* await query.countDocuments({ color: 'black' });
|
|
1934
|
+
*
|
|
1935
|
+
* const count = await query.where('color', 'black').countDocuments();
|
|
1936
|
+
* console.log('there are %d kittens', count);
|
|
1937
|
+
*
|
|
1938
|
+
* @param {Object} [filter] mongodb selector
|
|
1939
|
+
* @return {Query} this
|
|
1940
|
+
* @api public
|
|
1941
|
+
*/
|
|
1942
|
+
|
|
1943
|
+
Query.prototype.countDocuments = function(filter) {
|
|
1944
|
+
this.op = 'countDocuments';
|
|
1945
|
+
this._validate();
|
|
1946
|
+
|
|
1947
|
+
if (Query.canMerge(filter)) {
|
|
1948
|
+
this.merge(filter);
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
return this;
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* Executes a `countDocuments` Query
|
|
1956
|
+
* @returns the results
|
|
1957
|
+
*/
|
|
1958
|
+
Query.prototype._countDocuments = async function _countDocuments() {
|
|
1959
|
+
const conds = this._conditions;
|
|
1960
|
+
const options = this._optionsForExec();
|
|
1961
|
+
|
|
1962
|
+
debug('countDocuments', this._collection.collectionName, conds, options);
|
|
1963
|
+
|
|
1964
|
+
return this._collection.countDocuments(conds, options);
|
|
1965
|
+
};
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* Executes the query as a estimatedDocumentCount() operation.
|
|
1969
|
+
*
|
|
1970
|
+
* #### Example:
|
|
1971
|
+
*
|
|
1972
|
+
* query.estimatedDocumentCount();
|
|
1973
|
+
*
|
|
1974
|
+
* const count = await query.estimatedDocumentCount();
|
|
1975
|
+
* console.log('there are %d kittens', count);
|
|
1976
|
+
*
|
|
1977
|
+
* @return {Query} this
|
|
1978
|
+
* @api public
|
|
1979
|
+
*/
|
|
1980
|
+
|
|
1981
|
+
Query.prototype.estimatedDocumentCount = function() {
|
|
1982
|
+
this.op = 'estimatedDocumentCount';
|
|
1983
|
+
this._validate();
|
|
1984
|
+
|
|
1985
|
+
return this;
|
|
1986
|
+
};
|
|
1987
|
+
|
|
1988
|
+
/**
|
|
1989
|
+
* Executes a `count` Query
|
|
1990
|
+
* @returns the results
|
|
1991
|
+
*/
|
|
1992
|
+
Query.prototype._estimatedDocumentCount = async function _estimatedDocumentCount() {
|
|
1993
|
+
const conds = this._conditions;
|
|
1994
|
+
const options = this._optionsForExec();
|
|
1995
|
+
debug('estimatedDocumentCount', this._collection.collectionName, conds, options);
|
|
1996
|
+
return this._collection.estimatedDocumentCount(conds, options);
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* Declares or executes a distinct() operation.
|
|
2001
|
+
*
|
|
2002
|
+
* #### Example:
|
|
2003
|
+
*
|
|
2004
|
+
* await distinct(criteria, field)
|
|
2005
|
+
* distinct(criteria, field)
|
|
2006
|
+
* await distinct(field)
|
|
2007
|
+
* distinct(field)
|
|
2008
|
+
* await distinct()
|
|
2009
|
+
* distinct()
|
|
2010
|
+
*
|
|
2011
|
+
* @param {Object|Query} [criteria]
|
|
2012
|
+
* @param {String} [field]
|
|
2013
|
+
* @return {Query} this
|
|
2014
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Distinct
|
|
2015
|
+
* @api public
|
|
2016
|
+
*/
|
|
2017
|
+
|
|
2018
|
+
Query.prototype.distinct = function(criteria, field) {
|
|
2019
|
+
this.op = 'distinct';
|
|
2020
|
+
this._validate();
|
|
2021
|
+
|
|
2022
|
+
if (!field && typeof criteria === 'string') {
|
|
2023
|
+
field = criteria;
|
|
2024
|
+
criteria = undefined;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
if ('string' == typeof field) {
|
|
2028
|
+
this._distinctDoc = field;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
if (Query.canMerge(criteria)) {
|
|
2032
|
+
this.merge(criteria);
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
return this;
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* Executes a `distinct` Query
|
|
2040
|
+
* @returns the results
|
|
2041
|
+
*/
|
|
2042
|
+
Query.prototype._distinct = async function _distinct() {
|
|
2043
|
+
if (!this._distinctDoc) {
|
|
2044
|
+
throw new Error('No value for `distinct` has been declared');
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
const conds = this._conditions,
|
|
2048
|
+
options = this._optionsForExec();
|
|
2049
|
+
|
|
2050
|
+
return this._collection.distinct(this._distinctDoc, conds, options);
|
|
2051
|
+
};
|
|
2052
|
+
|
|
2053
|
+
/**
|
|
2054
|
+
* Declare and/or execute this query as an `updateMany()` operation. This function will update _all_ documents that match
|
|
2055
|
+
* `criteria`, rather than just the first one.
|
|
2056
|
+
*
|
|
2057
|
+
* _All paths passed that are not $atomic operations will become $set ops._
|
|
2058
|
+
*
|
|
2059
|
+
* #### Example:
|
|
2060
|
+
*
|
|
2061
|
+
* // Update every document whose `title` contains 'test'
|
|
2062
|
+
* mquery().updateMany({ title: /test/ }, { year: 2017 })
|
|
2063
|
+
*
|
|
2064
|
+
* @param {Object} [criteria]
|
|
2065
|
+
* @param {Object} [doc] the update command
|
|
2066
|
+
* @param {Object} [options]
|
|
2067
|
+
* @return {Query} this
|
|
2068
|
+
* @api public
|
|
2069
|
+
*/
|
|
2070
|
+
|
|
2071
|
+
Query.prototype.updateMany = function updateMany(criteria, doc, options) {
|
|
2072
|
+
return _update(this, 'updateMany', criteria, doc, options);
|
|
2073
|
+
};
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* Executes a `updateMany` Query
|
|
2077
|
+
* @returns the results
|
|
2078
|
+
*/
|
|
2079
|
+
Query.prototype._updateMany = async function() {
|
|
2080
|
+
return _updateExec(this, 'updateMany');
|
|
2081
|
+
};
|
|
2082
|
+
|
|
2083
|
+
/**
|
|
2084
|
+
* Declare and/or execute this query as an `updateOne()` operation. This function will _always_ update just one document,
|
|
2085
|
+
* regardless of the `multi` option.
|
|
2086
|
+
*
|
|
2087
|
+
* _All paths passed that are not $atomic operations will become $set ops._
|
|
2088
|
+
*
|
|
2089
|
+
* #### Example:
|
|
2090
|
+
*
|
|
2091
|
+
* // Update the first document whose `title` contains 'test'
|
|
2092
|
+
* mquery().updateMany({ title: /test/ }, { year: 2017 })
|
|
2093
|
+
*
|
|
2094
|
+
* @param {Object} [criteria]
|
|
2095
|
+
* @param {Object} [doc] the update command
|
|
2096
|
+
* @param {Object} [options]
|
|
2097
|
+
* @return {Query} this
|
|
2098
|
+
* @api public
|
|
2099
|
+
*/
|
|
2100
|
+
|
|
2101
|
+
Query.prototype.updateOne = function updateOne(criteria, doc, options) {
|
|
2102
|
+
return _update(this, 'updateOne', criteria, doc, options);
|
|
2103
|
+
};
|
|
2104
|
+
|
|
2105
|
+
/**
|
|
2106
|
+
* Executes a `updateOne` Query
|
|
2107
|
+
* @returns the results
|
|
2108
|
+
*/
|
|
2109
|
+
Query.prototype._updateOne = async function() {
|
|
2110
|
+
return _updateExec(this, 'updateOne');
|
|
2111
|
+
};
|
|
2112
|
+
|
|
2113
|
+
/**
|
|
2114
|
+
* Declare and/or execute this query as an `replaceOne()` operation. Similar
|
|
2115
|
+
* to `updateOne()`, except `replaceOne()` is not allowed to use atomic
|
|
2116
|
+
* modifiers (`$set`, `$push`, etc.). Calling `replaceOne()` will always
|
|
2117
|
+
* replace the existing doc.
|
|
2118
|
+
*
|
|
2119
|
+
* #### Example:
|
|
2120
|
+
*
|
|
2121
|
+
* // Replace the document with `_id` 1 with `{ _id: 1, year: 2017 }`
|
|
2122
|
+
* mquery().replaceOne({ _id: 1 }, { year: 2017 })
|
|
2123
|
+
*
|
|
2124
|
+
* @param {Object} [criteria]
|
|
2125
|
+
* @param {Object} [doc] the update command
|
|
2126
|
+
* @param {Object} [options]
|
|
2127
|
+
* @return {Query} this
|
|
2128
|
+
* @api public
|
|
2129
|
+
*/
|
|
2130
|
+
|
|
2131
|
+
Query.prototype.replaceOne = function replaceOne(criteria, doc, options) {
|
|
2132
|
+
this.setOptions({ overwrite: true });
|
|
2133
|
+
return _update(this, 'replaceOne', criteria, doc, options);
|
|
2134
|
+
};
|
|
2135
|
+
|
|
2136
|
+
/**
|
|
2137
|
+
* Executes a `replaceOne` Query
|
|
2138
|
+
* @returns the results
|
|
2139
|
+
*/
|
|
2140
|
+
Query.prototype._replaceOne = async function() {
|
|
2141
|
+
return _updateExec(this, 'replaceOne');
|
|
2142
|
+
};
|
|
2143
|
+
|
|
2144
|
+
/*!
|
|
2145
|
+
* Internal helper for updateMany, updateOne
|
|
2146
|
+
*/
|
|
2147
|
+
|
|
2148
|
+
function _update(query, op, criteria, doc, options) {
|
|
2149
|
+
query.op = op;
|
|
2150
|
+
|
|
2151
|
+
if (Query.canMerge(criteria)) {
|
|
2152
|
+
query.merge(criteria);
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
if (doc) {
|
|
2156
|
+
query._mergeUpdate(doc);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
if (utils.isObject(options)) {
|
|
2160
|
+
// { overwrite: true }
|
|
2161
|
+
query.setOptions(options);
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
return query;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
/**
|
|
2168
|
+
* Helper for de-duplicating "update*" functions
|
|
2169
|
+
* @param {Query} query The Query Object (replacement for "this")
|
|
2170
|
+
* @param {String} op The Operation to be done
|
|
2171
|
+
* @returns the results
|
|
2172
|
+
*/
|
|
2173
|
+
async function _updateExec(query, op) {
|
|
2174
|
+
const options = query._optionsForExec();
|
|
2175
|
+
|
|
2176
|
+
const criteria = query._conditions;
|
|
2177
|
+
const doc = query._updateForExec();
|
|
2178
|
+
|
|
2179
|
+
debug(op, query._collection.collectionName, criteria, doc, options);
|
|
2180
|
+
return query._collection[op](criteria, doc, options);
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* Declare and/or execute this query as a `deleteOne()` operation.
|
|
2185
|
+
*
|
|
2186
|
+
* #### Example:
|
|
2187
|
+
*
|
|
2188
|
+
* await mquery(collection).deleteOne({ artist: 'Anne Murray' })
|
|
2189
|
+
*
|
|
2190
|
+
* @param {Object|Query} [criteria] mongodb selector
|
|
2191
|
+
* @return {Query} this
|
|
2192
|
+
* @api public
|
|
2193
|
+
*/
|
|
2194
|
+
|
|
2195
|
+
Query.prototype.deleteOne = function(criteria) {
|
|
2196
|
+
this.op = 'deleteOne';
|
|
2197
|
+
|
|
2198
|
+
if (Query.canMerge(criteria)) {
|
|
2199
|
+
this.merge(criteria);
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
return this;
|
|
2203
|
+
};
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* Executes a `deleteOne` Query
|
|
2207
|
+
* @returns the results
|
|
2208
|
+
*/
|
|
2209
|
+
Query.prototype._deleteOne = async function() {
|
|
2210
|
+
const options = this._optionsForExec();
|
|
2211
|
+
delete options.justOne;
|
|
2212
|
+
|
|
2213
|
+
const conds = this._conditions;
|
|
2214
|
+
|
|
2215
|
+
debug('deleteOne', this._collection.collectionName, conds, options);
|
|
2216
|
+
return this._collection.deleteOne(conds, options);
|
|
2217
|
+
};
|
|
2218
|
+
|
|
2219
|
+
/**
|
|
2220
|
+
* Declare and/or execute this query as a `deleteMany()` operation. Always deletes
|
|
2221
|
+
* _every_ document that matches `criteria`.
|
|
2222
|
+
*
|
|
2223
|
+
* #### Example:
|
|
2224
|
+
*
|
|
2225
|
+
* await mquery(collection).deleteMany({ artist: 'Anne Murray' })
|
|
2226
|
+
*
|
|
2227
|
+
* @param {Object|Query} [criteria] mongodb selector
|
|
2228
|
+
* @return {Query} this
|
|
2229
|
+
* @api public
|
|
2230
|
+
*/
|
|
2231
|
+
|
|
2232
|
+
Query.prototype.deleteMany = function(criteria) {
|
|
2233
|
+
this.op = 'deleteMany';
|
|
2234
|
+
|
|
2235
|
+
if (Query.canMerge(criteria)) {
|
|
2236
|
+
this.merge(criteria);
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
return this;
|
|
2240
|
+
};
|
|
2241
|
+
|
|
2242
|
+
/**
|
|
2243
|
+
* Executes a `deleteMany` Query
|
|
2244
|
+
* @returns the results
|
|
2245
|
+
*/
|
|
2246
|
+
Query.prototype._deleteMany = async function() {
|
|
2247
|
+
const options = this._optionsForExec();
|
|
2248
|
+
delete options.justOne;
|
|
2249
|
+
|
|
2250
|
+
const conds = this._conditions;
|
|
2251
|
+
|
|
2252
|
+
return this._collection.deleteMany(conds, options);
|
|
2253
|
+
};
|
|
2254
|
+
|
|
2255
|
+
/**
|
|
2256
|
+
* Issues a mongodb findOneAndUpdate command.
|
|
2257
|
+
*
|
|
2258
|
+
* Finds a matching document, updates it according to the `update` arg, passing any `options`, and returns the found document (if any).
|
|
2259
|
+
*
|
|
2260
|
+
* #### Available options
|
|
2261
|
+
*
|
|
2262
|
+
* - `new`: bool - true to return the modified document rather than the original. defaults to true
|
|
2263
|
+
* - `upsert`: bool - creates the object if it doesn't exist. defaults to false.
|
|
2264
|
+
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
|
|
2265
|
+
*
|
|
2266
|
+
* #### Examples:
|
|
2267
|
+
*
|
|
2268
|
+
* await query.findOneAndUpdate(conditions, update, options) // executes
|
|
2269
|
+
* query.findOneAndUpdate(conditions, update, options) // returns Query
|
|
2270
|
+
* await query.findOneAndUpdate(conditions, update) // executes
|
|
2271
|
+
* query.findOneAndUpdate(conditions, update) // returns Query
|
|
2272
|
+
* await query.findOneAndUpdate(update) // returns Query
|
|
2273
|
+
* query.findOneAndUpdate(update) // returns Query
|
|
2274
|
+
* await query.findOneAndUpdate() // executes
|
|
2275
|
+
* query.findOneAndUpdate() // returns Query
|
|
2276
|
+
*
|
|
2277
|
+
* @param {Object|Query} [query]
|
|
2278
|
+
* @param {Object} [doc]
|
|
2279
|
+
* @param {Object} [options]
|
|
2280
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
|
|
2281
|
+
* @return {Query} this
|
|
2282
|
+
* @api public
|
|
2283
|
+
*/
|
|
2284
|
+
|
|
2285
|
+
Query.prototype.findOneAndUpdate = function(criteria, doc, options) {
|
|
2286
|
+
this.op = 'findOneAndUpdate';
|
|
2287
|
+
this._validate();
|
|
2288
|
+
|
|
2289
|
+
if (Query.canMerge(criteria)) {
|
|
2290
|
+
this.merge(criteria);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
// apply doc
|
|
2294
|
+
if (doc) {
|
|
2295
|
+
this._mergeUpdate(doc);
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
options && this.setOptions(options);
|
|
2299
|
+
|
|
2300
|
+
return this;
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* Executes a `findOneAndUpdate` Query
|
|
2305
|
+
* @returns the results
|
|
2306
|
+
*/
|
|
2307
|
+
Query.prototype._findOneAndUpdate = async function() {
|
|
2308
|
+
const conds = this._conditions;
|
|
2309
|
+
const update = this._updateForExec();
|
|
2310
|
+
const options = this._optionsForExec();
|
|
2311
|
+
|
|
2312
|
+
return this._collection.findOneAndUpdate(conds, update, options);
|
|
2313
|
+
};
|
|
2314
|
+
|
|
2315
|
+
/**
|
|
2316
|
+
* Issues a mongodb findOneAndReplace command.
|
|
2317
|
+
*
|
|
2318
|
+
* Finds a matching document, replaces it according to the `replacement` arg, passing any `options`, and returns the found document (if any).
|
|
2319
|
+
*
|
|
2320
|
+
* #### Available options
|
|
2321
|
+
*
|
|
2322
|
+
* - `new`: bool - true to return the modified document rather than the original. defaults to true
|
|
2323
|
+
* - `upsert`: bool - creates the object if it doesn't exist. defaults to false.
|
|
2324
|
+
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
|
|
2325
|
+
*
|
|
2326
|
+
* #### Examples:
|
|
2327
|
+
*
|
|
2328
|
+
* await query.findOneAndReplace(conditions, replacement, options) // executes
|
|
2329
|
+
* query.findOneAndReplace(conditions, replacement, options) // returns Query
|
|
2330
|
+
* await query.findOneAndReplace(conditions, replacement) // executes
|
|
2331
|
+
* query.findOneAndReplace(conditions, replacement) // returns Query
|
|
2332
|
+
* await query.findOneAndReplace(replacement) // returns Query
|
|
2333
|
+
* query.findOneAndReplace(replacement) // returns Query
|
|
2334
|
+
* await query.findOneAndReplace() // executes
|
|
2335
|
+
* query.findOneAndReplace() // returns Query
|
|
2336
|
+
*
|
|
2337
|
+
* @param {Object|Query} [query]
|
|
2338
|
+
* @param {Object} [replacement]
|
|
2339
|
+
* @param {Object} [options]
|
|
2340
|
+
* @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
|
|
2341
|
+
* @return {Query} this
|
|
2342
|
+
* @api public
|
|
2343
|
+
*/
|
|
2344
|
+
|
|
2345
|
+
Query.prototype.findOneAndReplace = function(criteria, replacement, options) {
|
|
2346
|
+
this.op = 'findOneAndReplace';
|
|
2347
|
+
this._validate();
|
|
2348
|
+
|
|
2349
|
+
if (Query.canMerge(criteria)) {
|
|
2350
|
+
this.merge(criteria);
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
// apply replacement
|
|
2354
|
+
if (replacement) {
|
|
2355
|
+
this._updateDoc = replacement;
|
|
2356
|
+
this.options = this.options || {};
|
|
2357
|
+
this.options.overwrite = true;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
options && this.setOptions(options);
|
|
2361
|
+
|
|
2362
|
+
return this;
|
|
2363
|
+
};
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* Executes a `findOneAndReplace` Query
|
|
2367
|
+
* @returns the results
|
|
2368
|
+
*/
|
|
2369
|
+
Query.prototype._findOneAndReplace = async function() {
|
|
2370
|
+
const conds = this._conditions;
|
|
2371
|
+
const replacement = this._updateForExec();
|
|
2372
|
+
const options = this._optionsForExec();
|
|
2373
|
+
|
|
2374
|
+
debug('findOneAndReplace', this._collection.collectionName, conds, replacement, options);
|
|
2375
|
+
return this._collection.findOneAndReplace(conds, replacement, options);
|
|
2376
|
+
};
|
|
2377
|
+
|
|
2378
|
+
/**
|
|
2379
|
+
* Issues a mongodb findOneAndDelete.
|
|
2380
|
+
*
|
|
2381
|
+
* Finds a matching document, removes it, returning the found document (if any).
|
|
2382
|
+
*
|
|
2383
|
+
* #### Available options
|
|
2384
|
+
*
|
|
2385
|
+
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
|
|
2386
|
+
*
|
|
2387
|
+
* #### Examples:
|
|
2388
|
+
*
|
|
2389
|
+
* await A.where().findOneAndDelete(conditions, options) // executes
|
|
2390
|
+
* A.where().findOneAndDelete(conditions, options) // return Query
|
|
2391
|
+
* await A.where().findOneAndDelete(conditions) // executes
|
|
2392
|
+
* A.where().findOneAndDelete(conditions) // returns Query
|
|
2393
|
+
* await A.where().findOneAndDelete() // executes
|
|
2394
|
+
* A.where().findOneAndDelete() // returns Query
|
|
2395
|
+
*
|
|
2396
|
+
* @param {Object} [filter]
|
|
2397
|
+
* @param {Object} [options]
|
|
2398
|
+
* @return {Query} this
|
|
2399
|
+
* @api public
|
|
2400
|
+
*/
|
|
2401
|
+
|
|
2402
|
+
Query.prototype.findOneAndDelete = function(filter, options) {
|
|
2403
|
+
this.op = 'findOneAndDelete';
|
|
2404
|
+
this._validate();
|
|
2405
|
+
|
|
2406
|
+
if (Query.canMerge(filter)) {
|
|
2407
|
+
this.merge(filter);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
// apply options
|
|
2411
|
+
options && this.setOptions(options);
|
|
2412
|
+
|
|
2413
|
+
return this;
|
|
2414
|
+
};
|
|
2415
|
+
|
|
2416
|
+
/**
|
|
2417
|
+
* Executes a `findOneAndRemove` Query
|
|
2418
|
+
* @returns the results
|
|
2419
|
+
*/
|
|
2420
|
+
Query.prototype._findOneAndDelete = async function() {
|
|
2421
|
+
const options = this._optionsForExec();
|
|
2422
|
+
const conds = this._conditions;
|
|
2423
|
+
|
|
2424
|
+
debug('findOneAndDelete', this._collection.collectionName, conds, options);
|
|
2425
|
+
return this._collection.findOneAndDelete(conds, options);
|
|
2426
|
+
};
|
|
2427
|
+
|
|
2428
|
+
/**
|
|
2429
|
+
* Add trace function that gets called when the query is executed.
|
|
2430
|
+
* The function will be called with (method, queryInfo, query) and
|
|
2431
|
+
* should return a callback function which will be called
|
|
2432
|
+
* with (err, result, millis) when the query is complete.
|
|
2433
|
+
*
|
|
2434
|
+
* queryInfo is an object containing: {
|
|
2435
|
+
* collectionName: <name of the collection>,
|
|
2436
|
+
* conditions: <query criteria>,
|
|
2437
|
+
* options: <comment, fields, readPreference, etc>,
|
|
2438
|
+
* doc: [document to update, if applicable]
|
|
2439
|
+
* }
|
|
2440
|
+
*
|
|
2441
|
+
* NOTE: Does not trace stream queries.
|
|
2442
|
+
*
|
|
2443
|
+
* @param {Function} traceFunction
|
|
2444
|
+
* @return {Query} this
|
|
2445
|
+
* @api public
|
|
2446
|
+
*/
|
|
2447
|
+
Query.prototype.setTraceFunction = function(traceFunction) {
|
|
2448
|
+
this._traceFunction = traceFunction;
|
|
2449
|
+
return this;
|
|
2450
|
+
};
|
|
2451
|
+
|
|
2452
|
+
/**
|
|
2453
|
+
* Executes the query
|
|
2454
|
+
*
|
|
2455
|
+
* #### Examples:
|
|
2456
|
+
*
|
|
2457
|
+
* query.exec();
|
|
2458
|
+
* await query.exec();
|
|
2459
|
+
* query.exec('update');
|
|
2460
|
+
* await query.exec('find');
|
|
2461
|
+
*
|
|
2462
|
+
* @param {String|Function} [operation]
|
|
2463
|
+
* @api public
|
|
2464
|
+
*/
|
|
2465
|
+
|
|
2466
|
+
Query.prototype.exec = async function exec(op) {
|
|
2467
|
+
if (typeof op === 'string') {
|
|
2468
|
+
this.op = op;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
assert.ok(this.op, 'Missing query type: (find, etc)');
|
|
2472
|
+
|
|
2473
|
+
const fnName = '_' + this.op;
|
|
2474
|
+
|
|
2475
|
+
// better error, because default would list it as "this[fnName] is not a function"
|
|
2476
|
+
if (typeof this[fnName] !== 'function') {
|
|
2477
|
+
throw new TypeError(`this[${fnName}] is not a function`);
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
return this[fnName]();
|
|
2481
|
+
};
|
|
2482
|
+
|
|
2483
|
+
/**
|
|
2484
|
+
* Executes the query returning a `Promise` which will be
|
|
2485
|
+
* resolved with either the doc(s) or rejected with the error.
|
|
2486
|
+
*
|
|
2487
|
+
* @param {Function} [resolve]
|
|
2488
|
+
* @param {Function} [reject]
|
|
2489
|
+
* @return {Promise}
|
|
2490
|
+
* @api public
|
|
2491
|
+
*/
|
|
2492
|
+
|
|
2493
|
+
Query.prototype.then = async function(res, rej) {
|
|
2494
|
+
return this.exec().then(res, rej);
|
|
2495
|
+
};
|
|
2496
|
+
|
|
2497
|
+
/**
|
|
2498
|
+
* Returns a cursor for the given `find` query.
|
|
2499
|
+
*
|
|
2500
|
+
* @throws Error if operation is not a find
|
|
2501
|
+
* @returns {Cursor} MongoDB driver cursor
|
|
2502
|
+
*/
|
|
2503
|
+
|
|
2504
|
+
Query.prototype.cursor = function() {
|
|
2505
|
+
if ('find' != this.op)
|
|
2506
|
+
throw new Error('cursor() is only available for find');
|
|
2507
|
+
|
|
2508
|
+
const conds = this._conditions;
|
|
2509
|
+
|
|
2510
|
+
const options = this._optionsForExec();
|
|
2511
|
+
if (this.$useProjection) {
|
|
2512
|
+
options.projection = this._fieldsForExec();
|
|
2513
|
+
} else {
|
|
2514
|
+
options.fields = this._fieldsForExec();
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
return this._collection.findCursor(conds, options);
|
|
2518
|
+
};
|
|
2519
|
+
|
|
2520
|
+
/**
|
|
2521
|
+
* Determines if field selection has been made.
|
|
2522
|
+
*
|
|
2523
|
+
* @return {Boolean}
|
|
2524
|
+
* @api public
|
|
2525
|
+
*/
|
|
2526
|
+
|
|
2527
|
+
Query.prototype.selected = function selected() {
|
|
2528
|
+
return !!(this._fields && Object.keys(this._fields).length > 0);
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
/**
|
|
2532
|
+
* Determines if inclusive field selection has been made.
|
|
2533
|
+
*
|
|
2534
|
+
* query.selectedInclusively() // false
|
|
2535
|
+
* query.select('name')
|
|
2536
|
+
* query.selectedInclusively() // true
|
|
2537
|
+
* query.selectedExlusively() // false
|
|
2538
|
+
*
|
|
2539
|
+
* @returns {Boolean}
|
|
2540
|
+
*/
|
|
2541
|
+
|
|
2542
|
+
Query.prototype.selectedInclusively = function selectedInclusively() {
|
|
2543
|
+
if (!this._fields) return false;
|
|
2544
|
+
|
|
2545
|
+
const keys = Object.keys(this._fields);
|
|
2546
|
+
if (0 === keys.length) return false;
|
|
2547
|
+
|
|
2548
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
2549
|
+
const key = keys[i];
|
|
2550
|
+
if (0 === this._fields[key]) return false;
|
|
2551
|
+
if (this._fields[key] &&
|
|
2552
|
+
typeof this._fields[key] === 'object' &&
|
|
2553
|
+
this._fields[key].$meta) {
|
|
2554
|
+
return false;
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
return true;
|
|
2559
|
+
};
|
|
2560
|
+
|
|
2561
|
+
/**
|
|
2562
|
+
* Determines if exclusive field selection has been made.
|
|
2563
|
+
*
|
|
2564
|
+
* query.selectedExlusively() // false
|
|
2565
|
+
* query.select('-name')
|
|
2566
|
+
* query.selectedExlusively() // true
|
|
2567
|
+
* query.selectedInclusively() // false
|
|
2568
|
+
*
|
|
2569
|
+
* @returns {Boolean}
|
|
2570
|
+
*/
|
|
2571
|
+
|
|
2572
|
+
Query.prototype.selectedExclusively = function selectedExclusively() {
|
|
2573
|
+
if (!this._fields) return false;
|
|
2574
|
+
|
|
2575
|
+
const keys = Object.keys(this._fields);
|
|
2576
|
+
if (0 === keys.length) return false;
|
|
2577
|
+
|
|
2578
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
2579
|
+
const key = keys[i];
|
|
2580
|
+
if (0 === this._fields[key]) return true;
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
return false;
|
|
2584
|
+
};
|
|
2585
|
+
|
|
2586
|
+
/**
|
|
2587
|
+
* Merges `doc` with the current update object.
|
|
2588
|
+
*
|
|
2589
|
+
* @param {Object} doc
|
|
2590
|
+
*/
|
|
2591
|
+
|
|
2592
|
+
Query.prototype._mergeUpdate = function(doc) {
|
|
2593
|
+
if (!this._updateDoc) this._updateDoc = {};
|
|
2594
|
+
if (doc instanceof Query) {
|
|
2595
|
+
if (doc._updateDoc) {
|
|
2596
|
+
utils.mergeClone(this._updateDoc, doc._updateDoc);
|
|
2597
|
+
}
|
|
2598
|
+
} else {
|
|
2599
|
+
utils.mergeClone(this._updateDoc, doc);
|
|
2600
|
+
}
|
|
2601
|
+
};
|
|
2602
|
+
|
|
2603
|
+
/**
|
|
2604
|
+
* Returns default options.
|
|
2605
|
+
*
|
|
2606
|
+
* @return {Object}
|
|
2607
|
+
* @api private
|
|
2608
|
+
*/
|
|
2609
|
+
|
|
2610
|
+
Query.prototype._optionsForExec = function() {
|
|
2611
|
+
const options = utils.clone(this.options);
|
|
2612
|
+
return options;
|
|
2613
|
+
};
|
|
2614
|
+
|
|
2615
|
+
/**
|
|
2616
|
+
* Returns fields selection for this query.
|
|
2617
|
+
*
|
|
2618
|
+
* @return {Object}
|
|
2619
|
+
* @api private
|
|
2620
|
+
*/
|
|
2621
|
+
|
|
2622
|
+
Query.prototype._fieldsForExec = function() {
|
|
2623
|
+
return utils.clone(this._fields);
|
|
2624
|
+
};
|
|
2625
|
+
|
|
2626
|
+
/**
|
|
2627
|
+
* Return an update document with corrected $set operations.
|
|
2628
|
+
*
|
|
2629
|
+
* @api private
|
|
2630
|
+
*/
|
|
2631
|
+
|
|
2632
|
+
Query.prototype._updateForExec = function() {
|
|
2633
|
+
const update = this._updateDoc == null ? {} : utils.clone(this._updateDoc);
|
|
2634
|
+
const ops = utils.keys(update);
|
|
2635
|
+
const ret = {};
|
|
2636
|
+
|
|
2637
|
+
for (const op of ops) {
|
|
2638
|
+
if (this.options.overwrite) {
|
|
2639
|
+
ret[op] = update[op];
|
|
2640
|
+
continue;
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
if ('$' !== op[0]) {
|
|
2644
|
+
// fix up $set sugar
|
|
2645
|
+
if (!ret.$set) {
|
|
2646
|
+
if (update.$set) {
|
|
2647
|
+
ret.$set = update.$set;
|
|
2648
|
+
} else {
|
|
2649
|
+
ret.$set = {};
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
ret.$set[op] = update[op];
|
|
2653
|
+
if (!~ops.indexOf('$set')) ops.push('$set');
|
|
2654
|
+
} else if ('$set' === op) {
|
|
2655
|
+
if (!ret.$set) {
|
|
2656
|
+
ret[op] = update[op];
|
|
2657
|
+
}
|
|
2658
|
+
} else {
|
|
2659
|
+
ret[op] = update[op];
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
this._compiledUpdate = ret;
|
|
2664
|
+
return ret;
|
|
2665
|
+
};
|
|
2666
|
+
|
|
2667
|
+
/**
|
|
2668
|
+
* Make sure _path is set.
|
|
2669
|
+
*
|
|
2670
|
+
* @parmam {String} method
|
|
2671
|
+
*/
|
|
2672
|
+
|
|
2673
|
+
Query.prototype._ensurePath = function(method) {
|
|
2674
|
+
if (!this._path) {
|
|
2675
|
+
const msg = method + '() must be used after where() '
|
|
2676
|
+
+ 'when called with these arguments';
|
|
2677
|
+
throw new Error(msg);
|
|
2678
|
+
}
|
|
2679
|
+
};
|
|
2680
|
+
|
|
2681
|
+
/*!
|
|
2682
|
+
* Permissions
|
|
2683
|
+
*/
|
|
2684
|
+
|
|
2685
|
+
Query.permissions = require('./permissions');
|
|
2686
|
+
|
|
2687
|
+
Query._isPermitted = function(a, b) {
|
|
2688
|
+
const denied = Query.permissions[b];
|
|
2689
|
+
if (!denied) return true;
|
|
2690
|
+
return true !== denied[a];
|
|
2691
|
+
};
|
|
2692
|
+
|
|
2693
|
+
Query.prototype._validate = function(action) {
|
|
2694
|
+
let fail;
|
|
2695
|
+
let validator;
|
|
2696
|
+
|
|
2697
|
+
if (undefined === action) {
|
|
2698
|
+
|
|
2699
|
+
validator = Query.permissions[this.op];
|
|
2700
|
+
if ('function' != typeof validator) return true;
|
|
2701
|
+
|
|
2702
|
+
fail = validator(this);
|
|
2703
|
+
|
|
2704
|
+
} else if (!Query._isPermitted(action, this.op)) {
|
|
2705
|
+
fail = action;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
if (fail) {
|
|
2709
|
+
throw new Error(fail + ' cannot be used with ' + this.op);
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
|
|
2713
|
+
/**
|
|
2714
|
+
* Determines if `conds` can be merged using `mquery().merge()`
|
|
2715
|
+
*
|
|
2716
|
+
* @param {Object} conds
|
|
2717
|
+
* @return {Boolean}
|
|
2718
|
+
*/
|
|
2719
|
+
|
|
2720
|
+
Query.canMerge = function(conds) {
|
|
2721
|
+
return conds instanceof Query || utils.isObject(conds);
|
|
2722
|
+
};
|
|
2723
|
+
|
|
2724
|
+
/**
|
|
2725
|
+
* Set a trace function that will get called whenever a
|
|
2726
|
+
* query is executed.
|
|
2727
|
+
*
|
|
2728
|
+
* See `setTraceFunction()` for details.
|
|
2729
|
+
*
|
|
2730
|
+
* @param {Object} conds
|
|
2731
|
+
* @return {Boolean}
|
|
2732
|
+
*/
|
|
2733
|
+
Query.setGlobalTraceFunction = function(traceFunction) {
|
|
2734
|
+
Query.traceFunction = traceFunction;
|
|
2735
|
+
};
|
|
2736
|
+
|
|
2737
|
+
/*!
|
|
2738
|
+
* Exports.
|
|
2739
|
+
*/
|
|
2740
|
+
|
|
2741
|
+
Query.utils = utils;
|
|
2742
|
+
Query.env = require('./env');
|
|
2743
|
+
Query.Collection = require('./collection');
|
|
2744
|
+
Query.BaseCollection = require('./collection/collection');
|
|
2745
|
+
module.exports = exports = Query;
|
|
2746
|
+
|
|
2747
|
+
// TODO
|
|
2748
|
+
// test utils
|