Create a CRUD App with Node and MongoDB: Lesson 12 of 17

Showing Real Events

Up Next

Creating Events

Autoplaying in 7 seconds!

Cancel

W

Table of Contents

    e'll use mongoose and the mongoose model we created to grab real events from our MongoDB database.

    To grab events:

    // grab all events, the {} matches all
    Event.find({}, (err, events) => {
    
        console.log(events);
    
    });
    
    // grab a single event with the slug ping-pong
    Event.findOne({ slug: 'ping-pong' }, (err, event) => {
    
        console.log(event);
    
    });

    Chris Sevilleja

    176 posts

    Founder of Scotch.io. Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.