Basically, I can't access my table information properly after it returns from MongoDB via the coronium:getObject( ) method and I'm hoping there's some quick and obvious solution that has escaped me.
I started by creating an object (a table named "data") and I'm able to access the elements of the table via the print( ) method with no problems
local data = {
name = "color",
[1] = { name = "red", value = 0},
[2] = { name = "yellow", value = 0},
[3] = { name = "blue", value = 0}
}
print( #data ) -- outputs 3
print( data[1].name ) -- outputs "red"
I then "push" the table object to MongoDB and get the objectID
mc:createObject( "soma", data, function(e)
if not event.error then
local r = e.result.objectId
print( r ) -- outputs "4262979782"
end
end)
But when I "pull" the object back to Corona and run the following code I am unable to properly access the data.
coronium:getObject( "soma", "4262979782", function(e)
local r = e.result
print( r.name .. " from result" ) -- outputs "color" print( #r .. " nodes from result" ) -- *** outputs 0
print( r[1].name .. " from result" ) -- *** Runtime error : attempt to index field '?' (a nil value)
end)