LearningNodeJS
LearningNodeJS copied to clipboard
Learning NodeJS, Chapter 8, Page 177
The following 2 lines (page 177): var db = require('./db.js'); var albums = db.albums;
I see the genius in it... I don't fully grasp it...;
It seems, the 2nd time I request the module, I have access to the collections...;
Hi!
I'm not 100% sure what you're asking?
--> When you require a module, that module is assigned to the variable you declared, i.e. db. You can then access anything exported from that module just like a var on an object, like a function or a collection, such as albums here.