Does pure MongoDB use schemas and models like Mongoose?
Does pure MongoDB use schemas and models like Mongoose ODM?
  


No, the MongoDB server (as at 4.0) does not have a concept of models or data relationships. Data is persisted in Documents which are stored on the server in a binary JSON-like serialization format called BSON.


  
  Does pure MongoDB have any validators?
  


The MongoDB server does support per-collection validation rules for inserting &amp; updating documents. In MongoDB 3.6 validation rules are defined using JSON Schema; earlier versions used MongoDB query operators to express validation rules.

Mongoose vs MongoDB schema validation

Typically the goal is to validate data as early as possible in order to provide timely feedback to the end user and avoid unnecessary round trips and processing. For example, validation can happen in the frontend UI, in your application layer, and at the database layer. Frontend UI often has basic validation based on data types and field masks, while custom validation, relationships, and business logic is generally better suited to your application layer. Database validation is a final check to ensure only data fitting an expected (but flexible) schema is persisted.

Using a proposed standard like JSON Schema potentially allows validation rules to be shared by multiple layers of your stack. There are JSON Schema Implementations available for most popular programming languages and browsers. Note: MongoDB's implementation of JSON Schema has an Extension which is the inclusion of a bsonType keyword to allow use of all MongoDB BSON field types.

A current limitation of MongoDB's server-side JSON Schema validation is that it does not provide a detailed report of errors: documents either succeed or fail validation. You may want to watch/upvote SERVER-20547:  Expose the reason an operation fails document validation in the MongoDB Jira issue tracker. Depending on your validation rules and options, failure will either result in an error (the insert/update is rejected) or a warning (the insert/update succeeds but results in a log message). Several of the JSON Schema implementations for application code have more detailed validation reporting suitable for end users.