Mongoose and Node.js multi tenant architecture Mongoose and Node.js multi tenant architecture mongoose mongoose

Mongoose and Node.js multi tenant architecture


You should add the ObjectId to the queries and not filter the data after you retrieved it from the database.

Using the ObjectId as extra query condition (which is implicitly AND'ed with any other conditions that you query for) will not only limit the amount of data that the database will have to return, but with proper indexes in place it will also be pretty fast.