Reputation: 12304
When declaring a mongoose schema, I noticed that using
mongoose.Schema({});
and
new mongoose.Schema({});
work.
Is there any difference? Which way is better?
Upvotes: 0
Views: 483
Reputation: 25121
Its the same thing. From the source:
if (!(this instanceof Schema)) return new Schema(obj, options);
If you omit new, it will just create an instance for you.
new
Upvotes: 6