The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Integrate MongoDB into your Express App

Integrate MongoDB into your Express App

9:09
This lesson will walk you through replacing the app's file system reliance with a live MongoDB database. We'll also use a popular ORM library to manage our database operations.
Watch this lesson now
Avatar
egghead.io

This lesson will walk you through replacing the app's file system reliance with a live MongoDB database. We'll also use a popular ORM library to manage our database operations.

Avatar
Nicholas

Really excellent course Ben. It would be great to see more on Mongoose/MongoDB with express.

Avatar
Ben

Thanks, Nicholas! I actually started on a new Mongoose lesson yesterday, and have 2 or 3 planned after that. :)

In reply to Nicholas
Avatar
prozbik

Hello, i tried to repeat this code, but i've got an err.
mongoose return an empty array.
exports.User= mongoose.model('User', userSchema, 'user'); works fine fith 3th param.

Avatar
Ben

Did you populate your database using the command shown?

mongoimport --db test --collection users --drop --file user_list.json

The default behavior of mongoose.model() is to use the plural form of the model name for the collection. So mongoose.model('User', userSchema) will look for a users (note the plural) collection.

In reply to prozbik
Avatar
prozbik

No Ben, i was used my own collection without importing.
Thanks, i understand now

In reply to Ben
Avatar
Pruyta

How about how to embed or link one schema with others. Could you please give us more example how to go down deep with mongoose would be nice.

I would love to know what is the best way to embed/link such schema in one collection.

Avatar
Ben

Thanks for the suggestion, Pruyta. I will try to integrate that into the next set of lessons.

In reply to Pruyta
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?