Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonecorsi/mongodb-query-validator
✅ Validate your MongoDB queries before executing them
https://github.com/simonecorsi/mongodb-query-validator
javascript mongodb nodejs query-validation query-validator typescript validation
Last synced: 26 days ago
JSON representation
✅ Validate your MongoDB queries before executing them
- Host: GitHub
- URL: https://github.com/simonecorsi/mongodb-query-validator
- Owner: simonecorsi
- License: mit
- Created: 2024-04-12T11:11:01.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-09-06T17:31:13.000Z (2 months ago)
- Last Synced: 2024-10-03T05:11:00.704Z (about 1 month ago)
- Topics: javascript, mongodb, nodejs, query-validation, query-validator, typescript, validation
- Language: TypeScript
- Homepage:
- Size: 1.15 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# mongodb-query-validator
> ✅ Zero Dependency MongoDB Query Operator Validator, why bother the database when you can save network rount-trip and CPU cycles?
## Table of Contents
- [About](#about)
* [Benefits](#benefits)
* [Use Cases](#use-cases)
- [Installation](#installation)
- [Usage](#usage)
- [Valid query Operators](#valid-query-operators)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)## About
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.
### Benefits
- **Error-Free Queries**: Say goodbye to query typos and syntax errors. Our validator catches them before they cause any trouble.
- **Efficiency Boost**: Streamline your development process by validating queries upfront, saving you time and resources.### Use Cases
- **Production Systems**: Enhance the robustness of production systems by validating queries before executing them in live environments, minimizing downtime and errors.
- **Development Environments**: Validate queries during development to catch errors early and streamline the debugging process.
- **Testing Processes**: Integrate query validation into testing pipelines to ensure query correctness and reliability.## Installation
```sh
npm i --save mongodb-query-validator
# OR
yarn add mongodb-query-validator
```## Usage
```ts
import { validateQuery } from './src/index';const { isValidQuery } = validateQuery({ myField: { nested: { $gte: 123 } } });
// isValidQuery = trueconst { isValidQuery, invalidFields } = validateQuery({
myField: { nested: { $exist: true } },
});
// isValidQuery = false
// invalidFields = ["myField.nexted.$exist"]
```## Valid query Operators
You can find all supported query operator [here](./src/allowed.ts)
## Contributing
Project is pretty simple and straight forward for what is my needs, but if you have any idea you're welcome.
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.
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'feat(scope): some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request## License
Distributed under the MIT License. See `LICENSE` for more information.
## Contact
Simone Corsi - [@im_simonecorsi](https://twitter.com/im_simonecorsi)