[Solved] Need two object types in one array with SimpleSchema in mongodb

Hello,

I have two object schema as following:
const moveSchema = new SimpleSchema({
move: {type: String}
});
const takebackSchema = new SimpleSchema({
takeBack:{ type: String, allowedValues: [“request”,“accept”,“reject”]},
});

and I want above two in one array like below:

actions: [moveSchema ,takebackSchema]

Above code should give me output like below:

actions:[
{
“move” : “e3”
},
{
“takeBack” : “request”
}
]

but I’m not able to do so. Please guide.

SimpleSchema.oneOf()

1 Like

@rjdavid
Thank you David.