A Parse.com plugin for Corona SDK development based on the full Parse REST API. Parse handles everything you need to store data securely and efficiently in the cloud. Store basic data types, including locations and photos, and query across them without spinning up a single server. Parse also features analytics, A/B testing, push, email, and more.
I have started porting my code from previous parse module to the new plugin.
Doing the following code; always failed saying missing password.
local function cb( ok, res, info ) print( ok, res, info ) end parse.request( parse.User.login ) :set("username", "userNameForTest") :set("password", "testing123") :response(cb)
In modParse we were using the method modParse:linkObject to link a user to an object. WIth the new plugin, how would you suggest we do that?
Also in modParse we were using the method :
modParse:linkFile( modParse.USER, objectId, “userData”, fileUri, fileUrl, onLinkFile ) to link a file to an object. With the new API, I am not sure to understand how to establish the link between the objectId and the file information.
parse.request( parse.Object.query, “test” )
:response(function( ok, res )
if not ok then
print(‘err’, res)
else
print(‘yes’, res)
print(res.color, res.yes)
end
end)
To retrieve the Object record you can use a “get” or a “query” (See here). In this case you are using a query, but it’s not properly built up. More on that in a sec.
Also, be mindful that “test” is the Class name on Parse, not your object identifier. You could consider “test” the category that your data objects are stored in. In the response of certain plugin calls to Parse you will find identifiers. Turning on debugging – after your Parse plugin “init” – can be helpful in these cases.
parse.config:debugEnabled( true )
How you manage and store these ids is up to you. Parses methodology is the User system, being the only entry point accessible by a users credentials. You can then create relations as needed to other Object ids using the User id as your “master” identifier.
Now, back to the code. On the “test” Class instance you have added 2 properties ( color and yes ), these are searchable with a parse.Object.query :
parse.trace( res ) --parse.trace() outputs table data
print( res.objectId ) --the actual id
end
end)
This would bring back all Objects from the “test” Class that contain a key called “color” that is equal to “red”. The plugin offers Macros (shortcuts) as well, so you could also use:
parse.macro.findWhereEqual( “test”, “color”, “red” ) --Class, key, value
:response(cb)
Generally you’ll be working with objectIds, so to fetch the Object as shown in your example, you would us a parse.Object.get :
@wgh92281 can you be more specific of what is the problem and what are you trying to achieve here ? Its very hard to understand what you want to do exactly and your code is really not easy to read. Please use proper code formating and focus on the code that does not work.
You should look at res.result (as you are doing a query in this case). Careful here, it is a table…
Also, I would suggest you use a debugger in the future and put a breakpoint in the callback method. You will then be able to look at the values and then find out very quickly of the returned data. Its the best way to learn how to deal with methods you are unsure of the data you receive.