Anyway if you only need store some data, use Parse: https://www.parse.com/ I have provided the Lua code to create and update data in Parse in other threads in the forum.
For example create a JSON object with the following code:
require"json"local headers ={["X-Parse-Application-Id"]="XXXXXXXXXXXXXX",
["X-Parse-REST-API-Key"]="XXXXXXXXXXXXXX",
["Content-Type"]="application/json"}-- Create a new object on Parse (<a href="https://www.parse.com/docs/rest#objects-classes" rel="nofollow">https://www.parse.com/docs/rest#objects-classes</a>)function ParseAPI.createObject(className, object)print("ParseAPI.createObject", className)if(className and object)thenlocal url ="<a href="https://api.parse.com/1/classes/"..className" rel="nofollow">https://api.parse.com/1/classes/"..className</a>
local method = UrlLoader.POST
-- Session token added to headers
--addSessionToken()
local body = json.encode(object)
--print("body", body)
local loader = UrlLoader.new(url, method, headers, body)
local function onComplete(event)
print("createObject() onComplete", event.data)
local response = json.decode(event.data)
local objectId = response.objectId
dataSaver.saveValue(className, objectId)
if (level_manager) then
level_manager:syncronize(response)
end
end
local function onError()
print("onError")
end
local function onProgress(event)
--print("onProgress: ")
end
loader:addEventListener(Event.COMPLETE, onComplete)
loader:addEventListener(Event.ERROR, onError)
--loader:addEventListener(Event.PROGRESS, onProgress)
else
print("Error: class name or object is nil")
end
end
Comments
This seems promising:
https://github.com/cloudwu/lua-mongo
https://github.com/openshift-quickstart/openshift-mongo-node-express-example
https://blog.openshift.com/getting-started-with-mongodb-on-nodejs-on-openshift/
Anyway if you only need store some data, use Parse: https://www.parse.com/ I have provided the Lua code to create and update data in Parse in other threads in the forum.
https://parse.com/docs/rest/guide#quick-reference
For example create a JSON object with the following code: