@nullix/zod-mongoose-studio 0.0.1

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