How to use different type of schema in an array in mongoose?

Viewed 1030

I have this schema:

var UserSchema = new Schema({
    documento: []
});

and this types of documents:

var RgSchema = new Schema({
    tipo: 'RG',
    numero: stringType(),
    orgaoEmissor: stringType(),
    dataExpedicao: dateType()
});

var CpfSchema = new Schema({
    tipo: 'CPF',
    numero: stringType()
});

how to set different types of schema (RgSchema or CpfSchema) in the documento: []?

A kind of this:

documento: [RgSchema || CpfSchema]
1 Answers
Related