CodeMasteryLab
Section 3

Database Integration

Connect Node.js with databases

Database Integration

Learn to integrate databases with Node.js applications.

MongoDB with Mongoose

npm install mongoose
const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/myapp');

const User = mongoose.model('User', {
  name: String,
  email: String
});

const user = new User({
  name: 'John',
  email: 'john@example.com'
});

await user.save();