Getting result table from user record and putting data into a tableView

Hi,

I have a tableView setup and I need to use data from mc:getMe( function(e) result list. I am trying to store the results into a table then use that table as my data for the tableView. For some reason it is not working. Here is my code:

mc:loginUser(userEmailCheck, userPasswordCheck, function( event1 )

mc:getMe( function(e)

orders = e.result.orders

for i = 1, #orders do

   myList:insertRow{

      rowHeight = 60,

      isCategory = false,

      rowColor = { 1, 1, 1 },

      lineColor = { 0.90, 0.90, 0.90 },

      params = {

         drinkName = orders[i].drinkName,

         cost = orders[i].cost

      }

   }

end

Here is what’s printing in my console:

                                      result:

Jun 15 10:22:50.273    name: David S

Jun 15 10:22:50.273    objectId: b3e24e99b1

Jun 15 10:22:50.273    orders:

Jun 15 10:22:50.273       0:

Jun 15 10:22:50.273          date: 

Jun 15 10:22:50.273          drinkName: Clark Kent

Jun 15 10:22:50.273          cost: Superman

Jun 15 10:22:50.273       1:

Jun 15 10:22:50.273          date: 

Jun 15 10:22:50.273          drinkName: Clark Kent

Jun 15 10:22:50.273          cost: Superman

Jun 15 10:22:50.273       2:

Jun 15 10:22:50.273          date: 

Jun 15 10:22:50.273          drinkName: Clark Kent

Jun 15 10:22:50.273          cost: Superman

My mongo user’s record looks like this:

orders: [

        {

            drinkName: “Clark Kent”,

            cost: “50”,

            date: “”

        },

        {

            drinkName: “Clark Kent”,

            cost: “50”,

            date: “”

        },

        {

            drinkName: “Clark Kent”,

            cost: “50”,

            date: “”

        }

    ]

Can someone please help! This is driving me nuts

Thanks!

Ok so looks like I needed to add null to the beginning of the table. This sorted it. The only problem I am having now is trying to insert new records into this table. I have posted this problem in another post.

 

Thanks!

I answered the question in your other post. For this issue you may be running into the MongoDB vs Lua indexing issue. MongoDB starts the index at 0 while Lua starts table indexes at 1. You can find some discussion on it here https://groups.google.com/forum/#!category-topic/coroniumio/u5K2N3MUX2s. 

I had planned on fixing this for Chris (develephant) but never got around to it. My thought is we could just have Coronium always offset the index by 1.  Not sure yet the best place to do that in the code or if it may have some residual effects. May look at that in the next few weeks.

Ok so looks like I needed to add null to the beginning of the table. This sorted it. The only problem I am having now is trying to insert new records into this table. I have posted this problem in another post.

 

Thanks!

I answered the question in your other post. For this issue you may be running into the MongoDB vs Lua indexing issue. MongoDB starts the index at 0 while Lua starts table indexes at 1. You can find some discussion on it here https://groups.google.com/forum/#!category-topic/coroniumio/u5K2N3MUX2s. 

I had planned on fixing this for Chris (develephant) but never got around to it. My thought is we could just have Coronium always offset the index by 1.  Not sure yet the best place to do that in the code or if it may have some residual effects. May look at that in the next few weeks.