mysql-live-select
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -71,2 +71,3 @@ /* mysql-live-select, MIT License ben@latenightsketches.com | ||
// Update schema included in ZongJi events | ||
var includeSchema = self.zongjiSettings.includeSchema; | ||
@@ -73,0 +74,0 @@ for(var i = 0; i < triggers.length; i++){ |
@@ -137,2 +137,19 @@ /* mysql-live-select, MIT License ben@latenightsketches.com | ||
LiveMysqlSelect.prototype.stop = function(){ | ||
var self = this; | ||
var index = self.base._select.indexOf(self); | ||
if(index !== -1){ | ||
self.base._select.splice(index, 1); | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
}; | ||
LiveMysqlSelect.prototype.active = function(){ | ||
var self = this; | ||
return self.base._select.indexOf(self) !== -1; | ||
}; | ||
module.exports = LiveMysqlSelect; |
{ | ||
"name": "mysql-live-select", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Live updating MySQL SELECT statements", | ||
@@ -5,0 +5,0 @@ "main": "lib/LiveMysql.js", |
@@ -114,2 +114,4 @@ # mysql-live-select | ||
`update` | `callback` | Update the result set. Callback function accepts `error, rows` arguments. Events will be emitted. | ||
`stop` | *None* | Stop receiving updates | ||
`active` | *None* | Return `true` if ready to recieve updates, `false` if `stop()` method has been called. | ||
@@ -116,0 +118,0 @@ As well as all of the other methods available on [`EventEmitter`](http://nodejs.org/api/events.html)... |
@@ -116,2 +116,3 @@ /* mysql-live-select, MIT License ben@latenightsketches.com | ||
setTimeout(function(){ | ||
conn.settings.skipDiff = false; | ||
test.done(); | ||
@@ -123,3 +124,4 @@ }, 100); | ||
.on('changed', error) | ||
.on('removed', error); | ||
.on('removed', error) | ||
.on('diff', error); | ||
@@ -135,2 +137,39 @@ querySequence(conn.db, [ | ||
}, | ||
stopAndActive: function(test){ | ||
var table = 'stop_active'; | ||
server.on('ready', function(conn, esc, escId, queries){ | ||
querySequence(conn.db, [ | ||
'DROP TABLE IF EXISTS ' + escId(table), | ||
'CREATE TABLE ' + escId(table) + ' (col INT UNSIGNED)', | ||
'INSERT INTO ' + escId(table) + ' (col) VALUES (10)', | ||
], function(results){ | ||
conn.select('SELECT * FROM ' + escId(table), [ { | ||
table: table, | ||
database: server.database | ||
} ]).on('update', function(rows){ | ||
if(rows.length > 0 && rows[0].col === 10){ | ||
test.ok(true); | ||
}else if(rows.length > 0 && rows[0].col === 15){ | ||
test.ok(this.active()); | ||
this.stop(); | ||
test.ok(!this.active()); | ||
conn.db.query('DELETE FROM ' + escId(table)); | ||
setTimeout(function(){ | ||
test.done(); | ||
}, 100); | ||
} | ||
}).on('removed', function(row, index){ | ||
throw new Error('should not be called'); | ||
}); | ||
querySequence(conn.db, [ | ||
'UPDATE ' + escId(table) + | ||
' SET `col` = 15' | ||
], function(results){ | ||
// ... | ||
}); | ||
}); | ||
}); | ||
}, | ||
error_no_db_selected: function(test){ | ||
@@ -137,0 +176,0 @@ server.on('ready', function(conn, esc, escId, queries){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77680
1896
139