node.js - understanding mongoose [Schema.Types.Mixed] -
is below schema defined correctly or writing
need writing: [schema.types.mixed]
or writing: [{}]
?
that is, if have array of dictionaries -- [{},{},{}] -- 1 can't predefine internal structure unless create schema , embed it. right interpretation of docs?
http://mongoosejs.com/docs/schematypes.html
var blogschema = new mongoose.schema({ title: string, writing: [{ post: string, two: number, 3 : number, 4 : string, 5 : [{ a: string, b : string, c : string, d: string, e: { type: date, default: date.now }, }] }], });
thanks.
that schema fine. defining object within array schema element implicitly treated own schema
object. such they'll have own _id
field, can disable explicitly defining schema _id
option disabled:
var blogschema = new mongoose.schema({ title: string, writing: [new schema({ post: string, two: number, 3 : number, 4 : string, 5 : [new schema({ a: string, b: string, c: string, d: string, e: { type: date, default: date.now }, }, {_id: false})] }, {_id: false})], });
Comments
Post a Comment