{"size": 1251, "ext": "js", "max_stars_repo_path": "app/list/list-items-view-model.js", "max_stars_repo_name": "mikealvares/visitorLogApp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/list/list-items-view-model.js", "max_issues_repo_name": "mikealvares/visitorLogApp", "max_issues_repo_issues_event_min_datetime": "2021-05-11T16:27:33.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T16:27:33.000Z", "max_forks_repo_path": "app/list/list-items-view-model.js", "max_forks_repo_name": "mikealvares/visitorLogApp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 32.9210526316, "max_line_length": 90, "alphanum_fraction": 0.4756195044}
const Sqlite = require("nativescript-sqlite");
const observableModule = require("tns-core-modules/data/observable");
const ObservableArray = require("tns-core-modules/data/observable-array").ObservableArray;

function ListItemsViewModel() {
    const items = new ObservableArray([]);
    (new Sqlite("pmxVisLog.db")).then(db => {
        db.all("SELECT * FROM visitors WHERE status=0").then(rows => {
            for(var row in rows) {
                otm = 'N/A'
                if(rows[row][8]!=null)
                    otm = rows[row][8];
                items.push({
                    id: rows[row][0], 
                    fnm: rows[row][1], 
                    cnm: rows[row][2], 
                    pno: rows[row][3], 
                    ino: rows[row][4], 
                    vnm: rows[row][5], 
                    rdt: rows[row][6], 
                    itm: rows[row][7],
                    otm: otm,
                });
            }
        }, error => {
            console.log("SELECT ERROR", error);
        });
    }, error => {
        console.log("OPEN DB ERROR", error);
    });
    const viewModel = observableModule.fromObject({
        items: items,
    });

    return viewModel;
}

module.exports = ListItemsViewModel;