How to use Parse.Query select for field Object type?

#1

Hi all,

I have a problems with Object field when update value.

Example:

days:{
  "1561939200": {
    "weekday": "Mon",
    "date": "2019-07-01",
    "slots": {
      "1000": false,
      "1030": false,
      "1100": false,
      "1130": false,
      "1200": false,
      "1230": false,
      "1300": false,
      "1330": false,
      "1400": false,
      "1430": false,
      "1500": false,
      "1530": false,
      "1600": false,
      "1630": false,
      "1700": false,
      "1730": false,
      "1800": false,
      "1830": false,
      "1900": false,
      "1930": false,
      "2000": false
    }
  },
  "1562025600": {
    "weekday": "Tue",
    "date": "2019-07-02",
    "slots": {
      "1000": false,
      "1030": false,
      "1100": false,
      "1130": false,
      "1200": false,
      "1230": false,
      "1300": false,
      "1330": false,
      "1400": false,
      "1430": false,
      "1500": false,
      "1530": false,
      "1600": false,
      "1630": false,
      "1700": false,
      "1730": false,
      "1800": false,
      "1830": false,
      "1900": false,
      "1930": false,
      "2000": false
    }
  }
}

I just want to update only days.1561939200.slots.1000 to true, but I can not use Parse.Query select with field days.1561939200.slots.1000.

Why do I need to do that, because I’m worried about update the same time more than 2 requests, slots will be overwrite with lasted update.

P/s: My English skill is not good, so difficult to explain (bow).

Thanks.

#2

You can use [] instead of {} and make some magic with addUnique and maybe some beforeSave to find the right object and update it.

Hope this will help you :slight_smile:

1 Like