I want to assign the same id value to roomID where the objects have the same type.
const Item = new Schema({
roomID: { type: String},
type: { type: String }
});
const Order = new Schema({
items: [{ type: Item }]
});
I want the output to be something like this:
{
id: "1234567890",
items: [
{
roomID:"5efd1db1803ec01b1c590e23"
type: "first",
// more data
},
{
roomID:"5efd1db1803ec01b1c590e23"
type: "first",
// more data
},
{
roomID:"5efd1db1803ec01b1c590e82"
type: "second",
// more data
},
],
};