Skip to content

Using the JSDO and DataSource components in a Node.js app

edselg edited this page May 18, 2018 · 1 revision

JSDO Version: 5.0.0 (Tech Preview for Node.js)

Setup

  • mkdir nodetest
  • cd nodetest
  • npm init -f
  • npm install @progress/jsdo-node

Run

  • node index.js

Code for index.js

var jsdo_core_1 = require("@progress/jsdo-core");
var progress = jsdo_core_1.progress;
var jsdo_node_1 = require("@progress/jsdo-node");
var DataSource = jsdo_node_1.DataSource;

var serviceURI = "https://oemobiledemo.progress.com/OEMobileDemoServices";
var catalogURI = "https://oemobiledemo.progress.com/OEMobileDemoServices/static/SportsService.json";

progress.data.getSession({
    serviceURI: serviceURI,
    catalogURI: catalogURI,
    authenticationModel: "anonymous"
}).then((object) => {
    console.log("DEBUG: getSession: result: ", object.result);
    var jsdo = new progress.data.JSDO({ name: 'Customer' });
    var dataSource = new DataSource({
        jsdo: jsdo,
        tableRef: "ttCustomer",
        // filter: "CustNum < 11"
        filter: {
            field: "CustNum",
            operator: "lte",
            value: 11
        }
    });
    dataSource.read()
        .subscribe((mydata) => {
            mydata.data.forEach((element) => {
                console.log(element.Name);
            });
        }, () => {
            console.log("Error while reading records.");
        });
}, (object) => {
    console.log("Error while creating session: ");    
    console.log("DEBUG: object: result: ", object.result, "info: ", object.info);    
});
Clone this wiki locally