MongoDB Composite Key

You can use objects for the _id field as well. The _id field is always unique. That way you kind of get a composite primary key: { _id : { a : 1, b: 1} } Just be careful when creating these ids that the order of keys (a and b in the example) matters, … Read more