Node.js Discussion Forums

There's no such thing as a stupid question. Ask. Discuss. Learn.

Hello there, I need help cant seem to figure out why the following code is not working. if remove the return statement am getting error that unhandled promises will be terminated

const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/mongo-exercises', {useNewUrlParser: true})
.then(() => console.log(' Successfuly connected to mongodb...'))
.catch(err => console.error('Ooops! something went wrong', err));

const courseSchema = new mongoose.Schema({
name: String,
tags: [ String ],
author: String,
isPublished: Boolean,
price: Number,
date: {type: Date, default:}

const Course = mongoose.model('Course', courseSchema);

async function updateCourse(id) {
const course = await Course.findById(id);

if (!course) return;

course.isPublished = false; = 'Kalisha';

// course.set({
// isPublished: true,
// author: 'Kalisha Malama'
// });

const result = await;


Kalisha Malama 6 months ago
  • Whitelisted Links