MongoDB

From 탱이의 잡동사니
Jump to navigation Jump to search

Overview

MongoDB 내용 정리.

Errors

db.collection is not a function

In mongodb version >= 3.0, that database variable is actually the parent object of the object it trying to access with database.collection('whatever').

To access the correct object, it need to reference its database name. <source lang=javascript> MongoClient.connect(db.url,(err,database) =>{

 const myAwesomeDB = database.db('myDatabaseNameAsAString')
 myAwesomeDB.collection('theCollectionIwantToAccess')

} </source>