Parse

I confirm that a query will always return a table array of the results as we are doing so many of them.

hi,

thanks again.i use your code and it is my whole code now

local function cb( ok, res ,info) for key, value in pairs( res) do print( key,value ) end end parse.request( parse.Object.query, "countertest" ) :where( { yes = "kkk" } ) --The search key query :response(cb)

console return=results table: 072F8038

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-12 20:50:14 [1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> results: \> 1: \> createdAt: 2015-12-11T07:58:19.547Z \> objectId: s6Au2jeHmF \> updatedAt: 2015-12-11T07:58:19.547Z \> yes: kkk \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* results table: 072F8038

and I change code 3,info instead of res

local function cb( ok, res ,info) for key, value in pairs( info) do print( key,value ) end end parse.request( parse.Object.query, "countertest" ) :where( { yes = "kkk" } ) --The search key query :response(cb)

it can show the info table key and value,i really don’t understand why res can not get value

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-12 20:51:17 [1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> results: \> 1: \> createdAt: 2015-12-11T07:58:19.547Z \> objectId: s6Au2jeHmF \> updatedAt: 2015-12-11T07:58:19.547Z \> yes: kkk \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* isError false responseHeaders table: 072910B8 responseType text status 200 url https://api.parse.com/1/classes/countertest?where=%7b%22yes%22%3a%22kkk%22%7d bytesEstimated 130 bytesTransferred 130

Hi,

Well, you actually didn’t use my code, my example was like so:

local function callback( ok, res )

  for _, result in ipairs( res ) do

    print( result.objectId )

  end

end

I am specifically using ipairs , not pairs. Notice the “_” meaning that is a “throwaway” value (an index), the result is a result object (keyed table) that you can use like any other, including result.objectId.

There is no “key” (only index), in a collection of result objects. So you must cycle through them. If you use pairs, it is not the same thing.

Any content with multiple results is going to be contained in a collection of some type, and this isn’t necessarily specific to Lua. But in this case it’s a Lua table array. Do you feel comfortable in knowing the difference between a table array and a keyed table? Because it’s a fundamental concept, for any Lua coding you are going to be doing. What are you going to do if you have multiple results? You must to have some way to contain them.

If you want one record, use .get methods with id, if you are performing a .query , you are commonly expecting multiple results, and possibly only 1 or no results. It’s up to you to adjust accordingly. This is a generally accepted practice and is directly related to the Parse API. 

If you are absolutely positive that your query will result in one and only one record, then you can access it directly like so:

function (ok, res)

  if ok then

    res[1].objectId

  end

end

I am not saying that I recommend that though. If you are looking for only one specific record, but don’t have an id, then try a Macro like findWhereEqual:

parse.macro.findWhereEqual( ‘countertest’, ‘yes’, ‘kkk’ )

:response(cb)

That should only return one result.

Cheers.

hi

i did try your code before,but it show nothing ,so i didn’t tell you,sorry, it my fault.

here is my code

parse.request( parse.Object.create, "countertest" ) :data({ yes = "kkk" } ) :response(function( ok, res ) if not ok then print('err', res) else print('create ok', res) end end) parse.macro.findWhereEqual( 'countertest', 'yes', 'kkk' ) :response(cb) local function cb( ok, res ) print("yes i am in begin of cb function") for \_, result in ipairs( res ) do print( result.objectId ) end print("yes i am in the end of cb function") end parse.request( parse.Object.query, "countertest" ) :where( { yes = "kkk" } ) --The search key query :response(cb)

it return

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-14 08:59:09 [1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> results: \> 1: \> createdAt: 2015-12-14T08:52:00.425Z \> objectId: 41jmOfO6IG \> updatedAt: 2015-12-14T08:52:00.425Z \> yes: kkk \> 2: \> createdAt: 2015-12-14T08:52:28.765Z \> objectId: RGwpfMevi8 \> updatedAt: 2015-12-14T08:52:28.765Z \> yes: kkk \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* yes i am in begin of cb function yes i am in the end of cb function \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-14 08:59:09 [2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> createdAt: 2015-12-14T08:59:07.681Z \> objectId: c0L0uNHfcq \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* create ok table: 0767E1E0 \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-14 08:59:09 [3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> code: 102 \> error: Invalid key $eq for find \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

here is my parse screen picture

code line 13

it return as below,i did try before and I post it before,but someone say he can not understand it, so I edit and delete it. 

\> code: 102 \> error: Invalid key $eq for find

and I try your code line 22,it return nothing

you can see line 19 and 25,this is nothing between them. 

yes i am in begin of cb function

yes i am in the end of cb function

plus,if I change code to

function (ok, res) if ok then res[1].objectId end end

simulator will show error window,it can not even run code

@wgh92281, There is many bugs in your code, that its hard to understand what you are really trying to accomplish here. Sometime you do not declare the callback, other time you do not define a name for your function…

How much experience do you have in coding ? and with Lua ?

I believe the best way we can help you is if you paste the whole source code from beginning to end that your are executing. No more snippets please as it is too hard for us to help you. Put the whole things here so we can understand the whole execution. 

thanks again,it is my fault,i didn’t make it clear.in previous post, my code is actually my whole code expect parse.config

I paste my whole code.  all I want is find the objectId that I created in no matter what way

local parse = require('plugin.parse') parse.config:applicationId("K4wlYq18ueOcW2Fj8uJ1EvcF5TD74QPKZOgoai83") parse.config:restApiKey("EnWOVpfkESrv4daVA6uFpvztHN2A17yrP2e4eyqd") parse.config:debugEnabled( true ) parse.request( parse.Object.create, "countertest" ) :data({ yes = 'kkk' } ) :response() parse.macro.findWhereEqual( 'countertest', 'yes', 'kkk' ) :response(function( ok, res ) if not ok then print('find err', res) else print('find ok', res.objectId ) end end) local function cb( ok, res ) print("yes i am in begin of cb function") if ok then print("yes i am in midlle of cb function") for \_, result in ipairs( res ) do print( result.objectId ) end end print("yes i am in the end of cb function") end parse.request( parse.Object.query, 'countertest' ) :where( { yes = 'kkk' } ) --The search key query :response(cb)

it return in simulator console

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-14 22:11:34 [1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> createdAt: 2015-12-14T22:11:37.782Z \> objectId: 5FBdnB6KK7 \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-14 22:11:34 [2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> code: 102 \> error: Invalid key $eq for find \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* find ok nil \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-14 22:11:34 [3] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> results: \> 1: \> createdAt: 2015-12-14T08:52:00.425Z \> objectId: 41jmOfO6IG \> updatedAt: 2015-12-14T08:52:00.425Z \> yes: kkk \> 2: \> createdAt: 2015-12-14T08:52:28.765Z \> objectId: RGwpfMevi8 \> updatedAt: 2015-12-14T08:52:28.765Z \> yes: kkk \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* yes i am in begin of cb function yes i am in midlle of cb function yes i am in the end of cb function

code line 11 return

> code: 102
> error: Invalid key $eq for find

code line 29 return nothing

if you have time, feel free to paste the whole code to your pc to run the code.you will see what I see.

this is the code without line number

local parse = require('plugin.parse') parse.config:applicationId("K4wlYq18ueOcW2Fj8uJ1EvcF5TD74QPKZOgoai83") parse.config:restApiKey("EnWOVpfkESrv4daVA6uFpvztHN2A17yrP2e4eyqd") parse.config:debugEnabled( true ) parse.request( parse.Object.create, "countertest" ) :data({ yes = 'kkk' } ) :response() parse.macro.findWhereEqual( 'countertest', 'yes', 'kkk' ) :response(function( ok, res ) if not ok then print('find err', res) else print('find ok', res.objectId ) end end) local function cb( ok, res ) print("yes i am in begin of cb function") if ok then print("yes i am in midlle of cb function") for \_, result in ipairs( res ) do print( result.objectId ) end end print("yes i am in the end of cb function") end parse.request( parse.Object.query, 'countertest' ) :where( { yes = 'kkk' } ) --The search key query :response(cb)

The following code is going to show you several ways to make this work, but please remember the following :

  • Everything is asynchronous

  • If you create objects with always the same parameters and if you are doing a query with those parameters, then you will get all the objects that share the same values (This was one of your mistake before)
     

    – ************************************************************************ – CREATING OUR OBJECT – ************************************************************************ local function createObject(value) local function objCreatedCallback( ok, res, info ) if ok == true then if res.code and res.error then print("something happen > ", res.code, res.error) else print(“this is the id of the " … value … " object you just created”, res.objectId ) end end end parse.request( parse.Object.create, “countertest” ) :data({ name = value } ) :response(objCreatedCallback) end print(“Creating our blue object…”) createObject(“blue”) print(“Creating our red object…”) createObject(“red”) – ************************************************************************ – QUERY ALL – ************************************************************************ print("Perform a queries to list all ‘countertest’ object class ") local function queryCallback( ok, res, info ) if ok == true then if res.code and res.error then print("something happen > ", res.code, res.error) else for _, result in ipairs( res ) do print( result.objectId ) end end end end parse.request( parse.Object.query, “countertest” ) :response(queryCallback) – ************************************************************************ – QUERY OBJECT TYPE OF COUNTERTEST – ************************************************************************ print("Perform a queries to find specific instances of an object, for example the blue one… ") local function queryCallback( ok, res, info ) if ok == true then if res.code and res.error then print("something happen > ", res.code, res.error) else for _, result in ipairs( res ) do print( result.objectId ) end end end end parse.request( parse.Object.query, “countertest” ) :where( { [“name”] = “blue” } ) :response(queryCallback)

thanks again, i am very appreciate your help.

step 1.

I copy all your code replace my main.lua and relaunch simulator

simulator console did show parse response,

but code as below don’t work, it didn’t print result.objectId,it print nothing

 for \_, result in ipairs( res ) do print( result.objectId ) end

step 2.

1.I know asynchronous mean I must wait some time to get the result.

2.you say don’t always create same parameters ,so I only create parameters once and then query.

​this is what I do

​I change class name from countertest to countertest3 and replace “blue” to “ha” and relaunch again only once

it still print nothing

step 3.

I delete create function,  only left query function as below is my whole code

local parse = require('plugin.parse') parse.config:applicationId("K4wlYq18ueOcW2Fj8uJ1EvcF5TD74QPKZOgoai83") parse.config:restApiKey("EnWOVpfkESrv4daVA6uFpvztHN2A17yrP2e4eyqd") parse.config:debugEnabled( true ) print("Perform a queries to list all 'countertest' object class ") local function queryCallback( ok, res, info ) if ok == true then if res.code and res.error then print("something happen \> ", res.code, res.error) else for \_, result in ipairs( res ) do print( result.objectId ) end end end end parse.request( parse.Object.query, "countertest3" ) :response(queryCallback)

simulator console still return  same result that I have see many times as blow.

I can see parse response on simulator console ,it mean parse did response result

but ​ code line 13 still dont’ work,it didn’t print anything

Perform a queries to list all 'countertest' object class \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\* Parse RESPONSE @ 12-15 06:10:45 [1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \> results: \> 1: \> createdAt: 2015-12-15T03:56:02.038Z \> name: ha \> objectId: p01QtAm3yU \> updatedAt: 2015-12-15T03:56:02.038Z \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

               

Try replacing this with :

for key, value in ipairs( res.results ) do print( "MyObject Id", value.objectId ) end

it works ,thanks all you guys. i know i have a lot to learn,again ,thanks

@wgh92281, my last suggestion prove that if you had put a breakpoint from the beginning of your problem, you would have found the solution right away. Please next time, use a debugger, put a breakpoint and investigate return value. It help you and it help us.

Hi Corona Community!  

Today I have a question, regarding checking already existing usernames via Parse.

On my login page, I am allowing my user to create an account(username + password).  I am using Parse backend for this.

 I need help writing code that will handle if the username they choose to use already exists on my parse user database!  

My code so far is below of my account creation file.

ALL help is appreciated! Thanks!

  1. –remove status bar
  2. display.setStatusBar( display.HiddenStatusBar )
  3.  
  4.  
  5.  
  6. –require modules
  7. local composer = require “composer”
  8. local scene = composer.newScene()
  9. local parse = require(‘plugin.parse’)
  10. parse.config:applicationId(“MY ID HERE”)
  11. parse.config:restApiKey(“MY REST API KEY HERE”)
  12. parse.config:debugEnabled( true )
  13. parse.showStatus = true
  14. local usernameInput
  15. local passwordInput
  16. local bg
  17. local createAccountBtn
  18. local createAccount
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. local function onUsername( event )
  27.     if ( “began” == event.phase ) then
  28.         – This is the “keyboard appearing” event.
  29.         – In some cases you may want to adjust the interface while the keyboard is open.
  30.  
  31.     elseif ( “submitted” == event.phase ) then
  32.         – Automatically tab to password field if user clicks “Return” on virtual keyboard.
  33.         native.setKeyboardFocus( passwordInput)
  34.     end
  35. end
  36.  
  37. local function onPassword( event )
  38.     – Hide keyboard when the user clicks “Return” in this field
  39.     if ( “submitted” == event.phase ) then
  40.         native.setKeyboardFocus( nil )
  41.     end
  42. end
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. –create account
  50. local function createAccount(event)
  51. if (event.phase == “began”) then 
  52.  
  53. parse.request( parse.User.query )
  54.   :where( { username = “”…usernameInput.text } )
  55.   :response(cb)
  56.   
  57.  
  58. –check here if username already exists!
  59.  
  60. –if it doesn’t exist, create account!
  61.  
  62. –add account to parse database
  63. parse.request( parse.User.create ) 
  64. :data( { username = “”…usernameInput.text, password = “”…passwordInput.text} )
  65. :response(cb)
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. end
  73. end
  74.  
  75.  
  76.  
  77. –create scene
  78. function scene:create( event )
  79. local group = self.view
  80.  
  81.  
  82.  
  83. bg = display.newRect(display.contentCenterX, display.contentCenterY, 800, 800)
  84. bg:setFillColor( 1, .6, 0 )
  85.  
  86.  
  87. – Create username text field
  88. usernameInput = native.newTextField( display.contentCenterX, 150, 260, 40 )
  89. usernameInput:setReturnKey( “next” )
  90. usernameInput.placeholder = " Username"
  91.  
  92. group:insert(usernameInput)
  93.  
  94. usernameInput:addEventListener( “userInput”, onUsername  )
  95.  
  96.  
  97.  
  98. – Create password text field
  99. passwordInput = native.newTextField( display.contentCenterX, display.contentCenterY, 260, 40 )
  100. passwordInput:setReturnKey( “go” )
  101. passwordInput.placeholder = " Password"
  102.  
  103. group:insert(passwordInput)
  104.  
  105. passwordInput:addEventListener( “userInput”, onPassword )
  106.  
  107.  
  108. – Create register account button
  109. createAccountBtn = display.newImage(“registerBtn.png”)
  110. createAccountBtn.x = display.contentCenterX; createAccountBtn.y = display.contentCenterY + 80
  111. createAccountBtn:scale(.15, .1 )
  112.  
  113.  
  114.  
  115.  
  116. end
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. –enter scene
  124. function scene:show( event )
  125. local group = self.view
  126. local phase = event.phase
  127.  
  128.  
  129.    if ( phase == “will” ) then
  130.      
  131.      
  132.      
  133.    elseif ( phase == “did” ) then
  134.  
  135.  
  136. createAccountBtn:addEventListener( “touch”, createAccount )
  137.  
  138.  
  139.  
  140.  
  141.  
  142. end
  143. end
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. –exit scene
  153. function scene:exitScene( event )
  154. local group = self.view
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164. end
  165.  
  166.  
  167.  
  168.  
  169.  
  170. –destroy scene
  171. function scene:destroyScene( event )
  172. local group = self.view
  173. local phase = event.phase
  174.  
  175.  
  176.  if ( phase == “will” ) then
  177.      
  178.      
  179.      
  180.    elseif ( phase == “did” ) then
  181.    
  182.    
  183.    
  184.    
  185.    
  186.  
  187. end
  188. end
  189.  
  190.  
  191.  
  192.  
  193. scene:addEventListener( “create”, scene)
  194. scene:addEventListener( “show”, scene)
  195. scene:addEventListener( “hide”, scene)
  196. scene:addEventListener( “destroy”, scene)
  197.  
  198. return scene

@nmichaud  

Do you have any advice or solution for my problem? I see your the expert here!  ;) 

Thanks

Just wanted to say thanks for making this. Works perfectly so far for us!

@Mgoldberg62401, you also creates a specific thread for this (https://forums.coronalabs.com/topic/60626-check-if-parse-username-already-exists-help/). Please always ask a question in one place as it is hard after that for the community to know where to look. Please look at the specific thread you created for an answer…

PS: Thanks for the good word, but I am not an expert, the real expert is @develephant who created an amazing plugin.

@nmichaud: You probably know more about its real-world usage than I.  :D Thanks again to helping out.

Cheers.

 @nmichuad  @develephant

Hi again! Your advise worked! I now have fully integrated a login and registration system in my app! Thanks for that!

HOWEVER, 

I have 1 more question!

How can I allow files to be shared from device to device that are on my parse database?

I need to allow a user to record his/her voice on their app, and be able to send that to another user of the app via parse.

I know I will need to use the “upload” and “download” parse commands. If you could point me in the right direction or give me some sample code that would be awesome!

Thanks!

@Mgoldberg62401, there are many ways to do what you want. As it simplest form you could do something like that (again this is a suggestion without knowing the scope of what you want to do)

  • Create a “voiceMsg” class in parse
  • Create a “voiceMsg” object and set the parameters details… (destination user Id, play yes/no, etc)
  • Use “parse.upload” to upload your file
  • Use “parse.macro.linkFileToObject” to link it to your newly created “VoiceMsg” object
  • notify your user with the “VoiceMsg” objectId or better simply notify your user that a msg is waiting for him
  • your user do a query on the msg waiting for him
  • download the file
  • do some clean up on “VoiceMsg” object

Again, this is just a quick and dirty way of doing this.

I hope this help

@nmichaud 

Thanks for your quick reply!

I understand each step clearly, thanks to you!  However, how do I query for the message or audio file through parse**?**

   I don’t quite get how the other device that is retrieving the file will be able to query for the message with that specific identifier.  How will the device know what the Object ID is or the unique file URL?

If you could please explain this more clearly, or even better provide a code example, that would be much appreciated!

Thanks!

@nmichaud