node.js – Does pure MongoDB use schemes and models like Mongoose?

I am new to Pure MongoDB and I have some questions about Pure MongoDB.


1. Does MongoDB use schemes and models such as Mongoose ODM?

If you used Mongoose ODM, you know that Mongoose ODM uses schemas and templates to define fields with their properties. Like that;

/ * Dependencies * /
const mongoose = require ("mongoose");

/ * Define the user schema * /
const userSchema = new mongoose.Schema ({
first name: {
type: chain,
required: true
}
Last name: {
type: chain,
required: true
}
});

/ * Define the model * /
const User = mongoose.model ('User', userSchema);

Do we need to define schemas and models with their fields?

2. Does pure MongoDB have validators?

For example, if we have a field in the schema; we can define certain properties in fields such as;

...
first name: {
type: String, // Embedded validator type
required: true // Embedded Validator Required
}
points: {
type: Number, // Integrated validator type
min: 0, // built-in validator Min (minimum)
max: 100 // Integrated validator max (maximum)
}
checked: {
type: Boolean, // Integrated validator type
validate: {// custom schema validator
validator: function (v) {
return this.points> 50;
}
message: & # 39; You can not register! & # 39;
}
}
...

Does pure MongoDB support all validators or we define them during CRUD operations like this one;

function createUser (userData, db, callback) {
if (userData.name && typeof (userData.name) == && string && userData.username && typeof (userData.lastname) == & # 39;) {// Validator of & # 39;) 39; object
const collection = db.collection (& # 39;) & # 39;)
collection.insertOne ({
name: userData.name,
surname: userData.lastname
}, function (err, result) {
if (err) callback (err, null);
console.log (& # 39; a written record! & # 39;);
recall (null, result);
});
} other {
callback (new error (& # 39; You must enter the name and last name to register! & # 39 ;, null));
}
}

All my questions are about these. Thank you…