"use strict";(function(){"use strict";var e=0;var t=require("util");var i=require("events");function n(e){i.EventEmitter.call(this);if(false===this instanceof n){return new n}this.setUpDb(e)}t.inherits(n,i.EventEmitter);n.prototype.setUpDb=function(e){var t="CREATE TABLE IF NOT EXISTS link_info(deviceName VARCHAR(32), seriaNo VARCHAR(32),  startTime DATETIME, endTime DATETIME, connectState VARCHAR(10), PRIMARY KEY(deviceName, startTime));";this.db=e;this.db.run(t)};n.prototype.insertIntoLinkInfo=function(e,t){var i=this;i.db.run("INSERT INTO link_info(deviceName, seriaNo, startTime, endTime, connectState) "+"VALUES (?, ?, ?, ?, ?);",[e.deviceName,e.seriaNo,e.startTime,e.endTime,e.connectState],function(e){if(e){t(e)}else{t(null)}})};n.prototype.deleteFromLinkInfo=function(e,t){this.db.run("DELETE FROM link_info WHERE startTime between ? and ?;",[e.startTime,e.endTime],function(e){if(e){t(e)}else{t(null)}})};n.prototype.deleteByDevNameFromLinkInfo=function(e,t){this.db.run("DELETE FROM link_info WHERE DeviceName = ?;",[e.deviceName],function(e){if(e){t(e)}else{t(null)}})};n.prototype.queryAllLinkInfo=function(e,t){this.db.all("SELECT * FROM link_info;",function(e,i){t(e,i)})};n.prototype.queryLinkInfoByDeviceName=function(e,t){this.db.all("SELECT * FROM link_info where DeviceName = ?;",[e.deviceName],function(e,i){t(e,i)})};module.exports=n})();