Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mysql-live-select

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-live-select - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

4

lib/LiveMysql.js

@@ -40,3 +40,5 @@ /* mysql-live-select, MIT License ben@latenightsketches.com

var curCache = self._queryCache[query];
if(curCache.updateTimeout === null && curCache.matchRowEvent(event)){
if((self.settings.checkConditionWhenQueued
|| curCache.updateTimeout === null)
&& curCache.matchRowEvent(event)){
curCache.invalidate();

@@ -43,0 +45,0 @@ }

{
"name": "mysql-live-select",
"version": "1.0.2",
"version": "1.0.3",
"description": "Live updating MySQL SELECT statements",

@@ -5,0 +5,0 @@ "main": "lib/LiveMysql.js",

@@ -54,2 +54,3 @@ # mysql-live-select [![Build Status](https://travis-ci.org/numtel/mysql-live-select.svg?branch=master)](https://travis-ci.org/numtel/mysql-live-select)

`minInterval` | `integer` | Pass a number of milliseconds to use as the minimum between result set updates. Omit to refresh results on every update. May be changed at runtime.
`checkConditionWhenQueued` | `boolean` | Set to `true` to call the condition function of a query on every binlog row change event. By default (when undefined or `false`), the condition function will not be called again when a query is already queued to be refreshed. Enabling this can be useful if external caching of row changes.

@@ -56,0 +57,0 @@ ```javascript

@@ -220,2 +220,62 @@ /* mysql-live-select, MIT License ben@latenightsketches.com

},
checkConditionWhenQueued: function(test) {
var table = 'check_condition_when_queued';
server.on('ready', function(conn, esc, escId, queries) {
// The following line should make no change but it is here for
// explicitness
conn.settings.checkConditionWhenQueued = false;
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) {
var conditionCountUnder1000 = 0;
var conditionCountOver1000 = 0;
conn.select('SELECT * FROM ' + escId(table), [ {
table: table,
database: server.database,
condition: function(row, newRow, rowDeleted) {
if(newRow.col < 1000) {
// Under 1000, checkConditionWhenQueued is false
// Will not bother rechecking the condition when query is
// queued to be refreshed already
conditionCountUnder1000++;
} else {
// Over 1000, checkConditionWhenQueued is true
// Condition will be checked with every row that changes
conditionCountOver1000++;
}
return true;
}
} ]).on('update', function(diff, rows){
if(rows.length > 0 && rows[0].col === 2000){
conn.settings.checkConditionWhenQueued = false;
test.equal(conditionCountUnder1000, 1);
test.equal(conditionCountOver1000, 4);
test.done();
}
});
querySequence(conn.db, [
'UPDATE ' + escId(table) + ' SET `col` = `col` + 5',
'UPDATE ' + escId(table) + ' SET `col` = `col` + 5',
'UPDATE ' + escId(table) + ' SET `col` = `col` + 5',
'UPDATE ' + escId(table) + ' SET `col` = 1000',
], function(results){
// Should have only had one condition function call at this point
conn.settings.checkConditionWhenQueued = true;
querySequence(conn.db, [
'UPDATE ' + escId(table) + ' SET `col` = `col` + 5',
'UPDATE ' + escId(table) + ' SET `col` = `col` + 5',
'UPDATE ' + escId(table) + ' SET `col` = `col` + 5',
'UPDATE ' + escId(table) + ' SET `col` = 2000',
], function(results){
// Should have seen all of these updates in condition function
});
});
});
});
},
pauseAndResume: function(test) {

@@ -222,0 +282,0 @@ var waitTime = 500;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc