Nested field - this collection cannot be found

hello,

im having an issue:
i have a nested field that i want to show images via fileviewer.
i cannot change the field directly because i think it is nested: when pressing on the little wheel it says: this collection cannot be found and when trying to edit the field from above it only shows the json viewer as the only option.

any help will be appreciated

thanks in advance,
nimrod

Hi @nmz ,

I might not understand the problem very well.
First of all, can you please fill the form below :

  • Project name:
  • Team name:
  • Environment name:
  • Agent type & version:
  • Recent changes made on your end if any:

And could you please describe where and what action are you trying to do, the expected behaviour and the actual behaviour ?

Best regards,

Shohan

hello, @shohanr

  • Project name: WescoverContentAdmin
  • Team name: Operators
  • Environment name: Development | nimrodmaltz
  • Agent type & version: “forest-express-mongoose”: “8.7.6”
  • Recent changes made on your end if any: added new collection

expected behavior:
see images array as images

actual behavior:
when trying to edit field to fileviewer it shows: this collection cannot be found

in short, i added a new collection with an array of media object that has type and public id, i want to use the id and a prefix to display images using the fileviewer widget, when trying to edit the document i cant switch to fileviewer only json viewer since its an array of objects and when trying to edit the nested field i get an error stated above.

thanks in advance,
nimrod

Hi @nmz

Can I have your schema of the specific collection and a sample of a record please ?

hi @shohanr,

thanks for replying,

my schema is:

import { Schema } from 'mongoose';

export const REVIEW_STATUSES = {
    submitted: 'submitted',
    approved: 'approved',
    rejected: 'rejected',
    deleted: 'deleted',
};

export const REVIEW_MEDIA_TYPES = {
    image: 'image',
};

export const REVIEW_METRICS = {
    general: 'general',
};

const schema = Schema(
    {
        status: { type: String, enum: Object.values(REVIEW_STATUSES) },
        reviewer: {
            userId: String,
            buyerSid: String,
            name: String,
            email: String,
        },
        subject: {
            makerSid: { type: String, index: true },
            makerName: String,
            makerContactDetails: String,
            orderSid: String,
            item: {
                name: String,
                popSid: { type: String, index: true },
                productSid: String,
                variantSid: String,
            },
        },
        content: {
            title: String,
            details: String,
            media: [
                {
                    type: { type: String, enum: Object.values(REVIEW_MEDIA_TYPES) },
                    publicId: String,
                },
            ],
            metrics: {
                general: { rating: Number }
            },
            mediaUsagePermitted: Boolean,
        },
        source: String,
        reviewedAt: Date,
        createdAt: Date,
        modifiedAt: Date,
        deletedAt: Date,
    }
);

export default schema;

and a record is:

{
    "_id" : ObjectId("62fd312ef85b04d573c1459c"),
    "subject" : {
        "item" : {
            "popSid" : "PHJxNdzmTt",
            "productSid" : "PRDHJxNdzmTt"
        },
        "makerSid" : "MB1BufmTtZ",
        "orderSid" : "ORD2106-WT724K"
    },
    "status" : "approved",
    "reviewer" : {
        "buyerSid" : "BBJ7GDy2GP",
        "userId" : "auth0|629d903d26a937006f7095d2"
    },
    "content" : {
        "media" : [
            {
                "_id" : ObjectId("6305ec8790aca087647d02c8"),
                "type" : "image",
                "publicId" : "wescover-image-store/j3e4hosgxhfgd9crblop"
            },
            {
                "_id" : ObjectId("6305ec8790aca087647d02c7"),
                "type" : "image",
                "publicId" : "wescover-dev-uploads/bqox1b3oielf6hksotew"
            }
        ],
        "metrics" : {
            "general" : {
                "rating" : NumberInt(5)
            }
        }
    },
    "reviewedAt" : ISODate("2022-08-17T18:19:26.173+0000"),
    "createdAt" : ISODate("2022-08-17T18:19:26.173+0000"),
    "modifiedAt" : ISODate("2022-08-29T11:35:13.866+0000"),
    "__v" : NumberInt(0),
    "deletedAt" : ISODate("2022-08-28T08:41:23.635+0000")
}

thanks in advance,
nimrod

Hi @nmz ,

We don’t provide fileviewer for nested fields but we do provide fileviewer for array of files.
A way to work around your use case will be a smart field creating the array you want in your forest/nested-images :

collection('nestedImages', {
  actions: [],
  fields: [{
    field: 'images',
    type: ['File'],
    get: (nestedImage) => {
      return nestedImage.content.media
        .map(({ publicId, type }) => {
          if (type === 'image') {
            return publicId;
          }
        });
    }
  }],
  segments: [],
  fieldsToFlatten: [],
});

Let me know if this has solved your problem.

Best regards,

Shohan

hi @shohanr ,

this works, thanks for all ur help

kind regards,
nimrod