1

I am starting a project were I am developing a web-OS App and I am trying to connect my app to a database, here is some code I found but I don't understand it, does anyone has a guide or videos on how to do this?

I don't understand where do I put the db name and credentials and how do I call the returning objects?

Example

var request = webOS.service.request("luna://com.palm.db", {
method: "get",
parameters: { 
    "ids" : ["J8rKTaBClIo"]
},
onSuccess: function (inResponse) {
    console.log( inResponse.results.length() + " object(s) is(are) retrieved");
    console.log( "Result: " + JSON.stringify(inResponse) );
    // To-Do something
},
onFailure: function (inError) {
    console.log("Failed to get the obejct(s)");
    console.log("[" + inError.errorCode + "]: " + inError.errorText);
    // To-Do something
    return;
}
});

Return Value

    {
      "returnValue": true,
"results": [
    {
        "_rev": 21,
        "sample": "sample1",
        "test": "test1",
        "_id": "J8rKTaBClIo",
        "_kind": "com.yourdomain.test:1"
    }
]
}

I want to grab this info and show it into a lable.

J.vee
  • 623
  • 1
  • 7
  • 26

1 Answers1

0

http://webostv.developer.lge.com/api/webos-service-api/db/ That looks like it connects to some sort of internal DB. There is a way to connect js to a SQL Server DB but that would require that the client has the activex object. How to connect to SQL Server database from JavaScript in the browser?

If I had to guess you would have to create API calls to connect to the azure DB. Which you should be able to use Azure Functions. Which for this would probably be perfect. Plus functions you only are charged for usage, so you are charged based on the number of calls made against the function. https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook

Ron
  • 421
  • 3
  • 9
  • Hi thanks for the links! and i see in the title it says in the browser, but mine is a Smart TV app for LG and idk if it works the same – MasterProgramer Jan 17 '19 at 15:40
  • The first link is for LG. I am presuming that more than likely it wouldn't have the activex component. Which is why I mentioned the Azure functions (since you have an Azure DB). The Azure functions would let you create API points that you could communicate with to get your data in a JSON format. Also, have you looked at CosmosDB? That has a whole API wrapper already for it, and I think it has a SQL server mode. https://learn.microsoft.com/en-us/rest/api/cosmos-db/ – Ron Jan 18 '19 at 18:39