mongoose find by query code example
Example 1: mongoose find() example
await MyModel.find({});
await MyModel.find({ name: 'john', age: { $gte: 18 } }).exec();
MyModel.find({ name: 'john', age: { $gte: 18 }}, function (err, docs) {});
await MyModel.find({ name: /john/i }, 'name friends').exec();
await MyModel.find({ name: /john/i }, null, { skip: 10 }).exec();
Example 2: findbyid mongoose
await Adventure.findById(id).exec();
Adventure.findById(id, function (err, adventure) {});
await Adventure.findById(id, 'name length').exec();