"Field not found" from within array when parent and sibling have duplicate fields

  • I have a schema which contains a datetime field “from”
  • There is then another JSON array field called “offers”
  • “Offers” also contains a “from” field
  • I am trying to use the following formula

Time.parse(offers.from).strftime("%Y-%m-%d")

But am getting an error

"error: Field 'offers' not found"

Changing offers.from to from references the parent from field, not the sibiling. If I change offers.from to offers.oFrom it works but this field name would not match my schema.

How should I fix this?

Desired result:

{
from: "2022-07-13T21:00:00Z",
date: "2022-07-13",
offers: [
    from: "2022-05-29T12:00:00Z,
    date: "2022-05-29"
    ]
}

Full schema

@LaurenceKs Can you post up your public schema link? Looks like the link you have here is your private link. At the bottom of the schema screen there is a public link you can share.

My bad

https://www.mockaroo.com/f8010c00

I’d like _to and _from to not have underscores to match my mongoose schema, currently I have to strip them from the json with search and replace

I’ve tried doing what you probably have already done and am getting the same negative results until I created a hidden field to store the date inside the nest. I then referenced the hidden field to return the appropriate date part.

This is probably due to the duplicate field names “from” and “to” but that would need to be confirmed by @mockaroo.

In the meantime here is your workaround -

https://www.mockaroo.com/f8010c00