How to handle MongoDB schema validation?

Ruud Verhoef

Reading the MongoDB manual, at the bottom, it say's that schema validation can be bypassed using the bypassDocumentValidation when doing an insert or update.

If I want to make sure that no one can put incorrect data into the database, should I only offer access through a API that can enforce these rules without them being bypassed?

L. Sanna

Two ways:

  1. as you said, simply wrap the request to mongo in your own method.

  2. you can authentify to mongo with a user which cannot bypass validation. A bit trickier to do.

See mongo docs: https://docs.mongodb.com/manual/reference/privilege-actions/#bypassDocumentValidation

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to handle changing parquet schema in Apache Spark

JAXB marshalling to XML - Is there a way to handle it when Schema validation fails?

How to handle hyphens in GraphQL Schema definitions

How to get mongodb schema dump

How to add multiple validation parameters in a marshmallow schema

How to handle this validation context?

How to handle hapi validation errors?

How to transfer data from SQL Server to mongodb (using mongoose schema for validation)

How to handle one to many in a star-schema?

How to handle Bridge table in Star Schema

Failed Validation with MongoDB Schema

How to validate list in mongodb schema?

how to clear _SCHEMA collection in mongodb

Laravel Validation Request, how to handle validation on update?

How to do conditional JSON schema validation

Golang mongodb driver error schema validation

How to handle user permissions in a database schema?

How to handle h:inputText validation?

How to initialise mongoose schema in mongoDb?

how to handle onfocusout, html validation

How to design Notifications schema for Mongodb

How to update in nested schema in mongodb?

MongoDb Json Schema Validation Draft 4

xml Schema validation: How return invalid elements

Validation Error in mongoDB while making a reference to another Schema?

MongoDB schema validation for unknown number of attributes?

How can I validate a password before hashing it in MongoDB User Schema using RegEx validation?

How can I validate a MongoDB document using a validation schema from a file?

How to handle IBAN validation in Javascript