Nested Objects declaration

This is a template you can use to report issues. You can also drag images, videos and include Preformatted text
Hello guys :slight_smile: I try to display a nested array of objects as a related Datas.
I add the field as an Array of object in the Parent object model .

According to the documentation , it should be displayed as a related Data on the left .
But i can only see it as a JSON in the summary view.
I can’t see any errors in my console.

I guess something on my declaration or in the data i’m sending may be incorrect …

const schema = mongoose.Schema({
  _id: mongoose.Schema.Types.ObjectId,
  ...,
  products: [{
    id: String,
    name: String,
    clientCustomization: [ClientCustomization],
    baseProduct: String,
    baseProduct_id: String,
    category_fr: String,
    quantity: Number,
    unitPrice: Number,
    margin: Number,
    textile: Boolean,
    custom: Boolean,
    supplierBaseProductId: String,
    owner: String,
    status: {
      type: String,
      enum: ['Active', 'Inactive', 'Locked'],
    },
    variations: {
      color: Variations,
      size: Variations,
    },
    fromStock: Boolean,
    shipperSpecificId: String,
    preOrder: Boolean,
    preOrderInfos: {
      moq: Number,
      startDate: Date,
      endDate: Date,
      shippingEstimate: Date,
      displayBandOnCustomImage: Boolean,
    },
    pricing: {
      margin: Number,
      customizationPrice: Number,
    },
  },
  ],
})

module.exports = mongoose.model('Orders', schema, 'Orders')

here -> Orders -> products

Expected behavior

Please describe here the behavior you are expecting.

Actual behavior

What is the current behavior?

Failure Logs

Please include any relevant log snippets, if necessary.

Context

Please provide any relevant information about your setup.

  • Package Version: 5.7
  • Express Version: 4.16.3
  • Sequelize Version:
  • Database Dialect: mongodb js
  • Database Version:
  • Project Name: Panopli

Hi @Tom,

Thanks for your message and sharing your issue!

I think I am reproducing your issue.
It’s probably due to the fact that you have deeper level inside your products (variations, preOrderInfos, pricing…).
Just to confirm, can you try to comment them out (the deeper level inside products), restart your server and tell me if you finally see your products as related data?

Thanks.

Ty adriguy that was the problem . If native model can’t handle nested fields i will need a smart collection i guess . Anyway thanks a lot

1 Like

I guess we could deal with those cases a bit better in the future.
I will add a feature request in our roadmap so that it could be tackled one day.
Thanks!