Schema: How to define fields within an Object or items within Array?

Hello, I would like to know if it is possible to define the items within an Array when creating the schema through parse, or the properties within an object, so far, I know we’re able to create a schema through the rest api, like:
/parse/schemas/Subscription

{
  "className": "Subscription",
  "fields": {
    "thirdPartyId": {
      "type": "String"
    },
    "page": {
      "type": "Number"
    },
    "originalTransactionId": {
      "type": "String"
    },
    "subscriptionGroupId": {
      "type": "String"
    },
    "transaction": {
      "type": "Array"
    },
    "details": {
      "type": "Object"
    },


  }
}

But I need to further define the schema, the transaction Array includes items that are objects which contains properties that are strings, dates, numbers, etc… We’re using a mongodb validator to ensure our data integrity and parse is failing at storing our data because it defines dates within our objects within the transaction Array as strings instead of dates. Likewise, how do I define the property types within the object details?

There is no way to define the schema of Array and Object fields via dashboard. What you can do:

  • Use Relation and Pointer types instead of Array and Object types, respectively;
  • Use Cloud Code beforeSave trigger to validate the data in Array and Object fields.
1 Like