Reputation: 652
Ok, I edited to make it clear.
I have sort kind of problem here. I cannot find the best way to do this:
I have a "table" at my MongoDB with my Mongoose Model like that:
var machineSchema = new Schema({
uuid : String,
data : String
});
So the UUID is my machine UUID. I can have something like this on the database:
{"uuid":"bla1","data":"RAM 1024MB"},
{"uuid":"bla1","data":"LINUX"},
{"uuid":"bla1","data":"CPU: Xeon"},
{"uuid":"bla2","data":"RAM 512MB"},
{"uuid":"bla2","data":"LINUX"},
{"uuid":"bla2","data":"CPU: Pentium Dual Core"}
What I want to do is, having two UUIDs (like bla1 and bla2) find what they have in common (data). So it should return:
{"uuid":"bla1","data":"LINUX"},
{"uuid":"bla2","data":"LINUX"}
or just
{"data":"LINUX"}
I could do two queries for bla1 and bla2 and them compare manually, but I think it has a better way to do that. I'm not used to Mongoose queries, there is anyway to do it? On MySQL I would do a Query with two subqueries only selecting the results that field1 matches between two. On Mongoose how should I do that?
Thanks!
Upvotes: 0
Views: 142
Reputation: 22001
It sounds like you require classic SQL 'join' functionality.
Unfortunately MongoDB (as well as most NoSQL databases) do not support joins, the functionality is more geared towards dealing with separate entities rather than sets.
Upvotes: 1