‘user’ refer to your database collection.
In MongoDB, each database has its own collection where you can name it anything.
In this example, the collection name is 'user'.
So if you don’t include it, your database can’t figure out which collection you target is.
More about collections: https://docs.mongodb.com/manual/core/databases-and-collections/#collections
However, I’m still confused about, where was it defined in the Glitch project, of the collection name being ‘user’ ?
Perhaps I’m overlooking some very obvious facts, however if someone could enlighten me, point out where in the project that ‘user’ was defined for db.collection, it’d be appreciated.
NOTE: This deserializeUser will throw an error until we set up the DB in the next step so comment out the whole block and just call done(null, null) in the function deserializeUser. Submit your page when you think you’ve got it right.
I did so, call done(null, null) and passed the challenge already.
I’m just wondering, in which challenge, was it ever that the we defined the collection ‘users’.
In my understanding, you have to at least define a variable in order to use it. Otherwise, I can’t see how we can access something in the mongodb database, without it being present (defined).
My confusion has been solved. I realized that (‘users’) is a collection name, as many replies to this thread mentioned already, that perhaps will be defined somewhere later in the ''Advanced Node and Express" challenge.
I was originally confused by the fact that, without even having it defined, the challenge went straight into .findOne (a search method). Usually, programs would define the collection first, before conducting .findOne method, perhaps somewhere in later challenge we’ll see ('users) being specifically defined and actually being loaded with user data.
(Otherwise it wouldn’t make sense to conduct database search without defining it)