Cronium getObjects Query Syntax

This will probably be an easy one for most of you, but I’m very inexperienced with Mongo queries.  Can someone please tell me what is wrong with this query syntax and how to fix it?

[lua]

local function gettingRequests(event)

     if not event.error then

          print("NumberRequests = "…#event.result)

          print("My Request Status = "…event.result[1].status)

          print("My Request Status = "…event.result[2].status)

     end

end

local queryTable = {

                       [“where”] = {

                                 ["$or"] = {

                                       {newFriendObjectId = { ["$eq"] = globals.userId } }, 

                                       {requesterObjectId = { ["$eq"] = globals.userId } }

                                                }

                                          } 

                                 }  

coronium:getObjects( “FriendRequests”, queryTable, gettingRequests )

[/lua]

Hi,

Have you tried wrapping the inner keys? May not make a difference, but something to try:

[“newFriendObjectId”] = …

Cheers.

Yes, that’s how I started. I’m moving over from Parse currently, and having them wrapped was normal syntax; not that I’m all that experienced with query syntax.

Anyways, the query works fine with one or the other individually. But when I add the “or” operator I get an error in mod_coronium saying I’m passing a function value.

Any help would be greatly appreciated.

Is there any way that anyone knows of to make this work with a single query call?

[lua]

coronium:getObjects( “FriendRequests”, { where = {requesterObjectId = { ["$eq"] = globals.userId } } }, OnGetObjects2 )

coronium:getObjects( “FriendRequests”, { where = {newFriendObjectId = { ["$eq"] = globals.userId } } }, OnGetObjects2 ) 

[/lua]

This actually works, but it seems silly to make two getObject calls.

I’m experiencing a similar issue with ["$in"].

local stringsList= { “cat”, “dog”, “penguin”}

coronium:getObjects( “favoriteThings”, 

{

    where = 

    {

        {

            animals = {["$in"] = stringsList} 

        }

    }

}

, handlerFunction)

This returns an empty table, even if there is a favoriteThings instance for which animals contains “penguin.”

I’m assisting with the same project that kthompson200 mentioned.  In addition to the issues we mentioned, any queries to the File directory are either returning an event.result with a nil objectID, or are causing a “Permission Denied” error.  Is it possible I didn’t set up the permissions correctly when I set up the ec2 instance?  Is there a function I need to call in order to grant our program access to files and MongoDB queries?

Hi,

Were the files manually uploaded or through the client?

Also, I’ll need to look into the other issues you mention. The Mongo driver for Lua is not perfect, especially when it comes to array conversions (due to Lua’s array index starting at 1) and this is generally why these errors pop up.

What version of Coronium are you running?

Cheers.

The files were uploaded programmatically, using Coronium:CreateObject.
 

We’re using Coronium for Corona SDK v1.92.5.

Hi,

Have you tried wrapping the inner keys? May not make a difference, but something to try:

[“newFriendObjectId”] = …

Cheers.

Yes, that’s how I started. I’m moving over from Parse currently, and having them wrapped was normal syntax; not that I’m all that experienced with query syntax.

Anyways, the query works fine with one or the other individually. But when I add the “or” operator I get an error in mod_coronium saying I’m passing a function value.

Any help would be greatly appreciated.

Is there any way that anyone knows of to make this work with a single query call?

[lua]

coronium:getObjects( “FriendRequests”, { where = {requesterObjectId = { ["$eq"] = globals.userId } } }, OnGetObjects2 )

coronium:getObjects( “FriendRequests”, { where = {newFriendObjectId = { ["$eq"] = globals.userId } } }, OnGetObjects2 ) 

[/lua]

This actually works, but it seems silly to make two getObject calls.

I’m experiencing a similar issue with ["$in"].

local stringsList= { “cat”, “dog”, “penguin”}

coronium:getObjects( “favoriteThings”, 

{

    where = 

    {

        {

            animals = {["$in"] = stringsList} 

        }

    }

}

, handlerFunction)

This returns an empty table, even if there is a favoriteThings instance for which animals contains “penguin.”

I’m assisting with the same project that kthompson200 mentioned.  In addition to the issues we mentioned, any queries to the File directory are either returning an event.result with a nil objectID, or are causing a “Permission Denied” error.  Is it possible I didn’t set up the permissions correctly when I set up the ec2 instance?  Is there a function I need to call in order to grant our program access to files and MongoDB queries?

Hi,

Were the files manually uploaded or through the client?

Also, I’ll need to look into the other issues you mention. The Mongo driver for Lua is not perfect, especially when it comes to array conversions (due to Lua’s array index starting at 1) and this is generally why these errors pop up.

What version of Coronium are you running?

Cheers.

The files were uploaded programmatically, using Coronium:CreateObject.
 

We’re using Coronium for Corona SDK v1.92.5.