I can’t find a clear answer online, are they the same thing? If I create a user model with mongoose that has different attributes is that the same thing as a schema, It’s just a blueprint of an object?
// Is this a constructor, an object, a model, or a schema?
const User = new mongoose.Model('User',{
name: {
type: String
}
});
//If I call this what is it?
const user = new User('John')
A schema is a rigid definition of the data involved and their types that will exist in the database, you’ll probably see this term quite frequently across different database systems
A model in mongoose instead provides an interface to the database, describing accessing data, which of course needs a description of the data itself too
It’s not as cleanly divided obviously, and some database language designers implement either one or the other