Thursday, 27 April 2017

Express mongoose populate array of subdocuments from POST

This is my Mongoose Schema:

const InvoiceSchema = new Schema({
name: { type: String, required: true },
description: { type: String },

items: [{
    product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product'},
    amount: { type: Number },
    name: { type: String, required: true },
    quantity: { type: Number },
    rate: { type: Number, required: true }
}],
createdBy: { type: Schema.ObjectId, ref: 'User', required: true },
}

Now I want to populate my Schema from POST Datas, My problem is I don't Know how to post my items (How do I name my fields)??

I use PostMan to post Datas.



via medKHELIFI

No comments:

Post a Comment