当前位置: 首页>>代码示例>>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;未经允许,请勿转载。