Message from JavaScript discussions

September 2020

— If console.log out of forEach even then users array is empty.


1. use map then you don't need to work with intermediate variables and fill them. you can then assign directly.

2. I have no idea of mongodb, but this looks inefficient. not sure what .lean() does. maybe there is some optimization magic

— And.. can't you populate the data directly with one query?

— Like in bookshelf I can do users.fetchAll({ withRelated: ['role'] })

— Lean converts the mongo document to plain object.

— This is the only problem. I would've done it but users are not stored in mongodb. Im fetching them from firebase

Message permanent page

— Unfortunately not. I know this's is quite inefficient but im doing as "they" suggested

— Oh god.

— Ok this is unfortunate :D

— Yes

— Supoose, if I've thousand users. How inefficient this would be.

— It'll go crazy with ton of queries.