Editing a field in a child collection does not apply

Feature(s) impacted

Editing a field in a child collection does not apply

Failure Logs

  • Agent technology: NodeJS (Express)
  • Agent (forest package) name & version: forest-express-mongoose (9.3.17)
  • Database type: MongoDB, Mongoose

Context

Since yesterday, when I edit my vauto field from forest, the change isn’t taken into account. No changes have been made on our end that would explain why it suddenly stops working. After several tests, it seems that it doesn’t work when I edit child schemas. (I hope I’m making myself clear!).

The main structure is Store. I am trying to modify a store. Here’s my data structure:

const StoreSchema = new mongoose.Schema(
  {
    name: { type: String, required: true },
    vauto: { type: VAutoSchema, required: false },
    exampleSchema: { type: ExampleSchema, required: false },
    exampleObject: {
      email: String,
      name: String
    },
  }
)

const VAutoSchema = new mongoose.Schema(
  {
    username: { type: String },
    entity: { type: String },
    skipLeads: { type: Boolean, default: false },
    pushOnDemand: { type: Boolean, default: false }
  },
  { _id: false }
)

If I edit vauto or exampleSchema (which doesn’t exist, but that’s just so you understand), then no changes will be made. However, editing exampleObject will work.

My API has middleware when forest modifies fields, and when I edit vauto, I get nothing:

[Forest] storeCreateOrUpdateMiddleware: {
  "data": {
    "id": "xxxx",
    "attributes": {},
    "relationships": {
      "group": {
        "data": {
          "type": "xxx",
          "id": xxxx""
        }
      }
    },
    "type": "Stores"
  }
}

But if I modify exampleObject I will have the values ​​in attributes.

From what I remember, we didn’t have this problem before. Has anything changed? And if not, what would the workaround be?

Thank you very much!

After several more tests, I realized that not all child collections are impacted. This is very surprising.

In the request response (PUT localhost:5007/forest/Store/xxxxxx) that forest initiates, the “vAuto” field, for example, is not returned in the JSON.

EDIT 2: After further testing, I realized that if the child collection isn’t empty, THEN I can edit it. But if the child collection is completely empty (so the child schema isn’t created yet), then it’s impossible to edit it ! This is the issue!!

Hi @CMonjo ,

We are sorry for the disturbance. Our team is looking into your issue.
I will let you know as soon as possible when a fix will be found.

Best regards,

Shohan

Could you please share us a video of how your reproduce your bug in private ?

1 Like

Hi Shohan !

I’ll send you a private message!

Thank you very much :slight_smile:

Hello @CMonjo

We released a fix, can you please test and confirm it’s working again ?

Nicolas

Hi @nbouliol

It works well, thank you very much!!

Camille

1 Like