What is the purpose of `new Schema` when creating schemas?

Viewed 99

I have seen two different syntaxes when using Mongoose. One uses new Schema to create a model why the other does not ...

Syntax 1

let schema = new Schema({ 
    // ... snip
});

Syntax 2

let schema = { // ... snip }

Both are used to create a model as follows:

const Class = mongoose.model(name, schema);
0 Answers
Related