Creating, Reading, Updating, and Deleting (CRUD) operations are basic functionality in web applications. In Node.js, we can use the package Mongoose to perform these tasks with MongoDB.
First, let’s install mongoose:
```
npm install mongoose
```
Next, let’s connect to mongodb:
```
const mongoose = require(‘mongoose’);
mongoose.connect(‘mongodb://localhost/test’, {useNewUrlParser: true, useUnifiedTopology: true});
```
Assuming we have an example MongoDB model named “User” like this:
```
const UserSchema = new Schema({
name: String,
email: String,
password: String
});
const User = mongoose.model(‘User’, UserSchema);
```
Here’s how you can perform CRUD operations:
user.save((error) => {
if (error) {
console.log(error);
} else {
console.log(“User saved successfully”);
}
});
```
// Find user with specific ID
User.findById(‘userID’, (error, user) => {
if (error) {
console.log(error);
} else {
console.log(user);
}
});
```
// Another faster way
User.updateOne({_id: ‘userID’}, {name: ‘New Name’}, (error) => {
if (error) {
console.log(error);
} else {
console.log(“User updated successfully”);
}
});
```
Please replace ‘userID’ and ‘New Name’ with the actual User ID and Name in your application. Also remember to handle errors appropriately for your application needs.
For some operation (like update and delete) mongoose provides two types of operations: one is directly on model and another is on instances. Both has their own advantages and disadvantages. Choose which best suits in your application.