monk mongodb find code example
Example 1: monk find
const users = monk(<connectionString>).get('users');
users.find({
age: 18
}).then((docs) => {
// All users with an age of 18 will be selected
});
users.find({}, {
fields: {
name: 1
}
}).then((docs) => {
// only the name field will be selected
});
Example 2: monk find fields
const users = monk(<connectionString>).get('users');
users.find({
userId: 3425
}, {
projection: {
name: 1
}
}).then((docs) => {
// only the name field will be selected
});