lib/connection.js
function onWrite(req) {
  if(!this.transaction || !this.watched || req.conn.id === this.id) {
    return false;
  }

  //console.dir(req.keys);
  //console.dir(req.args);

  var keys = req.keys || req.def.getKeys(req.args), i, key;
  for(i = 0;i < keys.length;i++) {
    key = '' + keys[i];
    //console.error('got change with key %s', key);
    //console.error('got change with value %s', value);
    //console.error('got change with conn id %j', req.conn.id);
    if(~this.watched.indexOf(key)) {
      //console.error('setting conflict on %s', keys[i]);
      //console.error('setting conflict from %s', req.conn.id);
      this.transaction.conflict = true;
      return true;
    }
  }
}
function onWrite(req) {
  if(!this.transaction || !this.watched || req.conn.id === this.id) {
    return false;
  }

  //console.dir(req.keys);
  //console.dir(req.args);

  var keys = req.keys || req.def.getKeys(req.args), i, key;
  for(i = 0;i < keys.length;i++) {
    key = '' + keys[i];
    //console.error('got change with key %s', key);
    //console.error('got change with value %s', value);
    //console.error('got change with conn id %j', req.conn.id);
    if(~this.watched.indexOf(key)) {
      //console.error('setting conflict on %s', keys[i]);
      //console.error('setting conflict from %s', req.conn.id);
      this.transaction.conflict = true;
      return true;
    }
  }
}
function onWrite ( req ) { if ( ! this . transaction || ! this . watched || req . conn . id === this . id ) { return false ; } //console.dir(req.keys); //console.dir(req.args); var keys = req . keys || req . def . getKeys ( req . args ) , i , key ; for ( i = 0 ; i < keys . length ; i ++ ) { key = '' + keys [ i ] ; //console.error('got change with key %s', key); //console.error('got change with value %s', value); //console.error('got change with conn id %j', req.conn.id); if ( ~ this . watched . indexOf ( key ) ) { //console.error('setting conflict on %s', keys[i]); //console.error('setting conflict from %s', req.conn.id); this . transaction . conflict = true ; return true ; } } }
Listener for write events emitted by the database.

Inspects the request object and if the request keys
match any keys being watched by this connection and
the request was from another connection then a conflict
if flagged on a transaction if a transaction exists.
Listener for write events emitted by the database .