I want to have a function to append (AddUnique) to a parse array column for multiple users in one request. What is the proper way of doing this? I know I could pass in a variable with an object ID to use in the URL, but this would still limit me to only updating a single object. I would like to append to an array column on multiple object’s. Ideas?
I haven’t found anything in mod_parse for handling arrays.
Here is what I have so far:
[lua]
function parseArray(Class, Column, Type, Data )
local function networkListener(event)
if event.phase == “ended” then
local t = json.decode(event.response)
if t.error then
print(t.error)
else
print(“Array was updated:”)
end
end
end
local appendArrayData = {
[Column] = {["__op"] = Type,[“objects”] = Data },
}
headers = {}
headers[“X-Parse-Application-Id”] = globals.appId
headers[“X-Parse-REST-API-Key”] = globals.apiKey
headers[“X-Parse-Session-Token”] = globals.sessionToken
headers[“Content-Type”] = “application/json”
local params = {}
params.headers = headers
params.body = json.encode ( appendArrayData )
network.request( “https://api.parse.com/1/classes/"..Class.."/”…globals.userId, “PUT”, networkListener, params)
end
myData = {“test1”, “test2”, “test3”}
parseArray("_User", “Column1”, “AddUnique”, myData)
[/lua]
Parse Docs: