mercredi 28 janvier 2015

Complex Schema with document and sub documents


Vote count:

0




Currently i am studying mongodb/mongoose because i am working with that, and i have a doubt:


I have a schema that support any names, but inside each, there are several dates, for example, he can choose A on 02/20/2014, or 02/26/2014.


So to populate this choices, i am trying to create roots schema and sub documents inside each one.



var mainSchema = new schema ({
name: String,
type: { type: String },
date: [ dateSchema ],
descrip: String,
});

var dateSchema = new Schema ({
date: {
type: Date
}
});


My question is simple: i am doing this right?


For example, a user create mainSchema Z, and them he wants put 5 dates inside:


01/01/2015 02/02/2015


I don't know if is clear, but i want that have a root schema accept several dates inside, not a schema for each date.



asked 44 secs ago







Complex Schema with document and sub documents

Aucun commentaire:

Enregistrer un commentaire