You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> ✅ Zero Dependency MongoDB Query Operator Validator, why bother the database when you can save network rount-trip and CPU cycles?
3
+
> ✅ Zero Dependency MongoDB Query Operator Validator. Why bother the database when you can save network round trips and CPU cycles?
6
4
7
5
## Table of Contents
8
6
9
7
<!-- toc -->
10
-
11
8
-[About](#about)
12
9
*[Benefits](#benefits)
13
10
*[Use Cases](#use-cases)
14
11
-[Installation](#installation)
15
12
-[Usage](#usage)
16
-
-[Valid query Operators](#valid-query-operators)
13
+
-[API](#api)
14
+
-[Valid query operators](#valid-query-operators)
17
15
-[Contributing](#contributing)
16
+
-[Development](#development)
18
17
-[License](#license)
19
18
-[Contact](#contact)
20
-
21
19
<!-- tocstop -->
22
20
23
21
## About
24
22
25
-
Do you ever find yourself squinting at your MongoDB queries, only to realize you've made a tiny typo that's causing a big headache? We've been there too. That's why we built this nifty little tool – to save you from those pesky errors and wasted database trips.
23
+
Do you ever find yourself squinting at your MongoDB queries, only to realize you've made a tiny typo that's causing a big headache? We've been there too. That's why this library exists: to catch those mistakes before they hit the database.
26
24
27
25
### Benefits
28
26
29
-
-**Error-Free Queries**: Say goodbye to query typos and syntax errors. Our validator catches them before they cause any trouble.
30
-
-**Efficiency Boost**: Streamline your development process by validating queries upfront, saving you time and resources.
27
+
-**Error-Free Queries** – Say goodbye to query typos and syntax errors. The validator catches them before they cause trouble.
28
+
-**Efficiency Boost** – Streamline your development process by validating queries upfront, saving you time and resources.
31
29
32
30
### Use Cases
33
31
34
-
-**Production Systems**: Enhance the robustness of production systems by validating queries before executing them in live environments, minimizing downtime and errors.
35
-
-**Development Environments**: Validate queries during development to catch errors early and streamline the debugging process.
36
-
-**Testing Processes**: Integrate query validation into testing pipelines to ensure query correctness and reliability.
37
-
38
-
<!-- GETTING STARTED -->
32
+
-**Production Systems** – Validate queries before executing them in live environments to minimize downtime and errors.
33
+
-**Development Environments** – Catch mistakes early while you're building features.
34
+
-**Testing Processes** – Integrate query validation into your testing pipelines to ensure correctness and reliability.
39
35
40
36
## Installation
41
37
@@ -45,47 +41,60 @@ npm i --save mongodb-query-validator
You can find all supported query operator [here](./src/allowed.ts)
63
+
-**query** – An object representing your MongoDB query.
64
+
-**maxDepth***(optional)* – Limit how deep the validator should traverse nested objects. `0` (default) means unlimited depth.
65
+
66
+
Returns an object with:
67
+
68
+
-`isValidQuery` – `true` if no invalid operators are found.
69
+
-`invalidFields` – an array of paths to the invalid fields.
70
+
71
+
Type definitions are available in [`types/index.d.ts`](./types/index.d.ts).
72
+
73
+
## Valid query operators
74
+
75
+
The full list of supported operators can be found in [`src/allowed.ts`](./src/allowed.ts).
68
76
69
77
## Contributing
70
78
71
-
Project is pretty simple and straight forward for what is my needs, but if you have any idea you're welcome.
79
+
Contributions are welcome! Please use [Conventional Commits](https://www.conventionalcommits.org/) when crafting your commit messages.
72
80
73
-
This projects uses [commitlint](https://commitlint.js.org/) with Angular configuration so be sure to use standard commit format or PR won't be accepted.
81
+
1. Fork the repository and create your branch (`git checkout -b feat/my-feature`).
82
+
2. Install dependencies with `npm i`.
83
+
3. Add your changes and tests.
84
+
4. Run the test suite with `npm test`.
85
+
5. Commit using the `feat`, `fix`, or other conventional prefixes.
86
+
6. Push your branch and open a pull request.
74
87
75
-
1. Fork the Project
76
-
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
77
-
3. Commit your Changes (`git commit -m 'feat(scope): some AmazingFeature'`)
78
-
4. Push to the Branch (`git push origin feature/AmazingFeature`)
79
-
5. Open a Pull Request
88
+
## Development
80
89
81
-
<!-- LICENSE -->
90
+
-**Build** – `npm run build` compiles TypeScript to `dist/`.
91
+
-**Tests** – `npm test` runs the tap test suite. Use this before submitting PRs.
92
+
-**Coverage** – `npm run coverage` generates an HTML coverage report.
82
93
83
94
## License
84
95
85
-
Distributed under the MIT License. See `LICENSE` for more information.
86
-
87
-
<!-- CONTACT -->
96
+
Distributed under the MIT License. See [`LICENSE`](LICENSE.md) for more information.
0 commit comments