✅ Validate your MongoDB queries before executing them
MIT License
✅ Zero Dependency MongoDB Query Operator Validator, why bother the database when you can save network rount-trip and CPU cycles?
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.
npm i --save mongodb-query-validator
# OR
yarn add mongodb-query-validator
import { validateQuery } from './src/index';
const { isValidQuery } = validateQuery({ myField: { nested: { $gte: 123 } } });
// isValidQuery = true
const { isValidQuery, invalidFields } = validateQuery({
myField: { nested: { $exist: true } },
});
// isValidQuery = false
// invalidFields = ["myField.nexted.$exist"]
You can find all supported query operator here
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 with Angular configuration so be sure to use standard commit format or PR won't be accepted.
git checkout -b feature/AmazingFeature
)git commit -m 'feat(scope): some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
Simone Corsi - @im_simonecorsi