Thanks for the help. I figured out how it works now and I’ll share what I learned below.
When I ran the command
db.{{collection}}:update( { \_id=idNum, data2.info1="New Info" } )
I got the error
2016/08/09 23:05:53 [error] 1923#0: \*51 lua entry thread aborted: runtime error: error loading module 'testApp.api' from file '/usr/local/cloud/apps/testApp/api.lua': /usr/local/cloud/apps/testApp/api.lua:45: '}' expected near '=' stack traceback: coroutine 0: [C]: in function 'require' /usr/local/cloud/lualib/cloud/input.lua:109: in function 'request' content\_by\_lua(cloud\_server.conf:116):5: in function \<content\_by\_lua(cloud\_server.conf:116):1\>, client: 192.168.71.1, server: localhost, request: "POST /testApp/updateData HTTP/1.1", host: “192.168.71.73"
In addition, I couldn’t get even this to run (same error)
db.{{collection}}:update( { \_id=idNum, data1=“New Info”} )
As far as I can tell the example in the MongoDB Corundum LS Docs has a typo, though I think the description above it is accurate. It seems that the “update” method requires 2 tables, one query and one update. However the example only uses one table, which I couldn’t get to work. For Docs reference, if we assume the player=“Sally” exists, then the input could be {player=“Sally”},{player=“Sally”, score = 300}.
In addition, it is worth noting that a command like
db.{{collection}}:update( { \_id=idNum}, updateTable )
Replaces the entire document with updateTable. For example
—Let’s say we have this table in the “data” collection {\_id=1,data1=“None”,data2=“None”} —If we call local updateTable = {data1=“New Info"} db.data:update( { \_id=1}, updateTable ) —Our new table will be {\_id=1,data1=“New Info”}
If instead you want to replace the value of data1 then you need to use a command like this
db.data:update({ \_id=1}, {["$set"]= {data1="New Info"}})
Putting Steven Warren’s suggestion together with that information, we can replace subtable data as follows:
—Let’s say we have this table in the “data” collection {\_id=1,data1=“None”,data2=“None”,data3={data1="None"}} —Let's replace the data inside the subtable data3 --Note that ["data3.data1"] must be used instead of data3.data1 --for the system to interpret the "." correctly db.data:update({ \_id=1}, {["$set"]= {["data3.data1"]="New Info"}}) —Our new table will be the desired table {\_id=1,data1=“None”,data2=“None”,data3={data1="New Info"}}
I hope this helps anyone else who may have been confused.