MongoDB

From 탱이의 잡동사니
Revision as of 14:57, 6 January 2018 by Pchero (talk | contribs) (Created page with "== Overview == MongoDB 내용 정리. == Errors == === db.collection is not a function === In mongodb version >= 3.0, that database variable is actually the parent object of...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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>