Mongoose Schema
noun
say it: “MOON-goos SKEE-muh” /ˈmunˌɡus ˈskimə/
In Mongoose, a description of the fields one kind of document has, their types and their rules.
What is a Mongoose schema?
A Mongoose schema describes one kind of document: each field, its type and its rules, such as required or min. Mongoose checks every document against it before saving.
import mongoose from "mongoose";
const workoutSchema = new mongoose.Schema({
type: { type: String, required: true },
minutes: { type: Number, min: 1 },
date: { type: Date, default: Date.now },
});
In a sentence
- “The Mongoose schema says every workout needs a type and at least 1 minute.”
- “Because of its Mongoose schema, a workout with minutes: -5 was refused before it reached the database.”
Level: Journeyman · More MongoDB terms at this level
Updated