const mongoose = require(
"mongoose"
);
const connectionObject = mongoose.createConnection(URI, {
useNewUrlParser:
true
,
useUnifiedTopology:
true
,
});
const studentSchema =
new
mongoose.Schema({
name: { type: String, required:
true
},
age: { type: Number, required:
false
},
rollNumber: { type: Number },
});
const Student = connectionObject.model(
'Student'
, studentSchema);
const Customer = connectionObject.model(
'Customer'
,
new
mongoose.Schema({
name: String,
address: String,
orderNumber: Number,
}));
const aggregate = Student.aggregate([{ $project: { age: 1 } }])
aggregate.model(Customer);
console.log(aggregate.model() === Customer);