Search code examples
jsonrestparse-platformlinden-scripting-language

Parse.com Rest API - Manipulating Arrays


Due to limitations of an embedded scripting language that I am using (Linden Scripting Language, LSL for short), I must rely on the REST api for Parse.com, and unfortunately the REST api documentation is unclear or incomplete on some subjects.

This is (roughly speaking) what my objects will look like:

{
    "objectId": string_val,
    "createdAt": date_val,
    "updatedAt": date_val,
    "OwnerKey": string_val,
    "DocID": string_val,
    "Data": []
}

What I need to do are two things:

  1. I need to be able to append string values to the Data array, if they do not already exist. "add-unique" is the name of the operation, but I have no idea how to use it from the REST api.
  2. I need to be able to load the array in chunks. For example, first load elements 0 through 31, then elements 32 through 63, and so on. This is due to limitations on both memory usage (64kb total) and a limit on the size of http response bodies (16kb), and I expect the total list size to become quite large.

I know not everyone is proficient with LSL (and be thankful that you are not!), so answers do not necessarily need to be in LSL. I understand Python code, so answers can be in that. I also understand the CURL examples that parse.com uses in their REST documentation, so answers can also be in that.


Solution

    1. This is directly addressed in the REST API Guide under "Arrays" and was the first result when I searched for "AddUnique" over https://parse.com/docs/rest.

    2. Objects are limited to 128 KB so storing a big array of objects like this is not recommended. Can you use a Relation field instead as recommended in the Relations guide?