Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning NodeJS, Chapter 8, Page 177 #36

Open
ghost opened this issue Jun 13, 2017 · 1 comment
Open

Learning NodeJS, Chapter 8, Page 177 #36

ghost opened this issue Jun 13, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 13, 2017

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...;

@marcwan
Copy link
Owner

marcwan commented Sep 27, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant