當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lokijs.loadDatabase函數代碼示例

本文整理匯總了TypeScript中lokijs.loadDatabase函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript loadDatabase函數的具體用法?TypeScript loadDatabase怎麽用?TypeScript loadDatabase使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了loadDatabase函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: updateBoostCool

export function updateBoostCool(req: express.Request, res: express.Response) {
    var value = null;

    if (req.query.Enabled == "1") {
        value = (new Date()).toJSON();
    }

    var db = new loki('panel.json');
    db.loadDatabase({}, function () {
        var panel = null;
        try {
            var panel = db.getCollection("panel").get(1);
        }
        catch (ex) {
            updateBoostCool(req, res);
            return;
        }

        if (value == null) {
            panel.coolOverRide = value;
        }
        else {
            panel.heatOverRide = null;
            panel.coolOverRide = value;
        }

        panel = ProcessPanel(panel);
        db.save();
        res.setHeader('Content-Type', 'application/json');
        res.send(JSON.stringify({ panel: panel }));
    });
}
開發者ID:msdickinson,項目名稱:Contest,代碼行數:32,代碼來源:index.ts

示例2: setupDB

function setupDB() {
    var db = new loki('panel.json')
    db.loadDatabase({}, function () {
        if (db.collections.length == 1 && db.getCollection("panel").data.length == 1) {
            var panel = db.getCollection("panel").get(1);
            panel.os = os.platform();
            panel.fanOn = false;
            panel.heatOn = false;
            panel.coolOn = false;
            panel = ProcessPanel(panel);
            panel.date = new Date();
            db.save();
            setTimeout(update, 1000);
        } else {
            var children = db.addCollection('panel')
            var schedule = new Array();
            for (var i = 0; i < (4 * 24); i++) {
                var interval: any = {};
                interval.on = false;
                interval.temperature = 0;
                schedule.push(interval);
            }
            if (children.count() > 0)
                return;

            children.insert({ fanOn: false, heatOn: false, coolOn : false, heatEnabled: 1, coolEnabled: 1, scheduleOn: 0, temperature: 80, setTemperature: 75, coolOverRide: null, heatOverRide: null, schedule: schedule, state: "" })
            var panel = children.get(1);
            panel = ProcessPanel(panel);
            panel.os = os.platform();
            panel.date = new Date();
            db.save();
            setTimeout(update, 1000);
        }
    });
}
開發者ID:msdickinson,項目名稱:Contest,代碼行數:35,代碼來源:index.ts

示例3: update

function update(sense) {

   

    var db = new loki('panel.json');
    db.loadDatabase({}, function () {
        var panel = null;
        try {
            var panel = db.getCollection("panel").get(1);
        }
        catch (ex) {
            update(sensorLib);
            return;
        } 
      
        if (panel.os == "linux") {
            var sensorLib = sense;
            if (sense == null) {
                sensorLib = require("node-dht-sensor");
                sensorLib.initialize(22, 4);
            }
            var readout = sensorLib.read();
            console.log('Temperature: ' + ((readout.temperature.toFixed(2) * 9/5) + 32) + 'C, ' + 'humidity: ' + readout.humidity.toFixed(2) + '%');
            panel.temperature = Math.round((readout.temperature.toFixed(2) * 9 / 5) + 32);

        }

        panel = ProcessPanel(panel);
        panel.date = new Date();
        db.save();
        setTimeout(function () { update(sensorLib) }, 5000);
    });

}
開發者ID:msdickinson,項目名稱:Contest,代碼行數:34,代碼來源:index.ts

示例4: settings

export function settings(req: express.Request, res: express.Response) {
    var db = new loki('panel.json');
    db.loadDatabase({}, function () {
        var panel = null;
        try {
            var panel = db.getCollection("panel").get(1);
        }
        catch (ex) {
            settings(req, res);
            return;
        }
        res.render('settings', { panel: JSON.stringify(panel) });
    });
}
開發者ID:msdickinson,項目名稱:Contest,代碼行數:14,代碼來源:index.ts

示例5: getPanelState

export function getPanelState(req: express.Request, res: express.Response) {
    var db = new loki('panel.json');
    db.loadDatabase({}, function () {
        var panel = null;
        try {
            var panel = db.getCollection("panel").get(1);
        }
        catch (ex) {
            getPanelState(req, res);
            return;
        }
        res.setHeader('Content-Type', 'application/json');
        res.send(JSON.stringify({ panel: panel }));
    });
};
開發者ID:msdickinson,項目名稱:Contest,代碼行數:15,代碼來源:index.ts

示例6: updateScheduleEnabled

export function updateScheduleEnabled(req: express.Request, res: express.Response) {
    var db = new loki('panel.json');
    db.loadDatabase({}, function () {
        var panel = null;
        try {
            var panel = db.getCollection("panel").get(1);
        }
        catch (ex) {
            updateScheduleEnabled(req, res);
            return;
        }
        panel.scheduleOn = req.query.Enabled;
        panel = ProcessPanel(panel);
        db.save();
        res.setHeader('Content-Type', 'application/json');
        res.send(JSON.stringify({ panel: panel }));
    });
}
開發者ID:msdickinson,項目名稱:Contest,代碼行數:18,代碼來源:index.ts

示例7: updateTemperature

export function updateTemperature(req: express.Request, res: express.Response) {
    var db = new loki('panel.json');
    db.loadDatabase({}, function () {
        var panel = null;
        try {
            var panel = db.getCollection("panel").get(1);
        }
        catch (ex) {
            updateTemperature(req, res);
            return;
        }
        panel.setTemperature = parseInt(req.query.temperature);  
        panel.coolOverRide = null;
        panel.heatOverRide = null;
        panel.scheduleOn = 0;
        panel = ProcessPanel(panel);
        db.save();
        res.setHeader('Content-Type', 'application/json');
        res.send(JSON.stringify({ panel: panel }));
    });

}
開發者ID:msdickinson,項目名稱:Contest,代碼行數:22,代碼來源:index.ts

示例8: Promise

 return new Promise(resolve => {
     db.loadDatabase({}, () => {
         const _collection = db.getCollection(colName) || db.addCollection(colName)
         resolve(_collection)
     })
 })
開發者ID:softmantk,項目名稱:multer-typescript,代碼行數:6,代碼來源:utils.ts


注:本文中的lokijs.loadDatabase函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。