I have two collections: orders and customers. I want to fetch all orders along with the customer's name and email.
// orders: { _id, customerId, total, status }
// customers: { _id, name, email }
I tried $lookup but it's killing performance on large datasets (~2M orders). Should I be using indexes differently, or is there a better aggregation strategy?
Priya Nair
asked 2 months ago1
Answers51
Upvotes5670
ViewsI'm running a Node.js app inside Docker and trying to connect to a MongoDB instance running on my host machine. The connection string mongodb://localhost:27017 fails inside the container.
Error: connect ECONNREFUSED 127.0.0.1:27017
I know localhost inside Docker refers to the container itself. How do I properly connect to the host's MongoDB?
I'm designing a schema for a blog platform. I have posts, comments, and users. I can't figure out when to embed vs reference:
What are the rules of thumb here?
Sofia Greco
asked 3 months ago2
Answers110
UpvotesSofia Greco
asked 2 months ago1
Answers19
Upvotes6150
Views10100
Views