lib/write.js
function (graph, opts, params) {
    var self = this;
    var updatedNodes = graph.allNodes;
    if (opts.restrictToComp) {
      updatedNodes = graph.allNodes.filter(function(node) {
        return node.comp && node.comp.name == opts.restrictToComp;
      });
    }

    function assign(statements, varName, hash) {
      params[varName] = hash;
      if (opts.additive) {
        _.forEach(hash, function(val, key) {
          statements.push(varName + '.`' + key + '`={' + varName + '}.`' + key + '`');
        });
      } else {
        statements.push(varName + '={' + varName + '}');
      }
    }

    return 'SET ' + updatedNodes.reduce(function(statements, node) {
      // set props
      var props = node.props;
      if (props[self.db.options.id]) props = _.omit(props, self.db.options.id);
      
      if (node.comp) assign(statements, '__rel_' + node.name, props._rel || {});
      
      props = _.omit(props, '_rel');
      assign(statements, node.name, props);

      // set timestamps
      if (!node.model.usingTimestamps) return statements;
      statements.push(getSetCreatedTimestampStatement(node));
      statements.push(node.name + '.' + node.model.updatedField + ' = timestamp()');

      return statements;
    }, []).join(',');
  }
function (graph, opts, params) {
    var self = this;
    var updatedNodes = graph.allNodes;
    if (opts.restrictToComp) {
      updatedNodes = graph.allNodes.filter(function(node) {
        return node.comp && node.comp.name == opts.restrictToComp;
      });
    }

    function assign(statements, varName, hash) {
      params[varName] = hash;
      if (opts.additive) {
        _.forEach(hash, function(val, key) {
          statements.push(varName + '.`' + key + '`={' + varName + '}.`' + key + '`');
        });
      } else {
        statements.push(varName + '={' + varName + '}');
      }
    }

    return 'SET ' + updatedNodes.reduce(function(statements, node) {
      // set props
      var props = node.props;
      if (props[self.db.options.id]) props = _.omit(props, self.db.options.id);
      
      if (node.comp) assign(statements, '__rel_' + node.name, props._rel || {});
      
      props = _.omit(props, '_rel');
      assign(statements, node.name, props);

      // set timestamps
      if (!node.model.usingTimestamps) return statements;
      statements.push(getSetCreatedTimestampStatement(node));
      statements.push(node.name + '.' + node.model.updatedField + ' = timestamp()');

      return statements;
    }, []).join(',');
  }
function ( graph , opts , params ) { var self = this ; var updatedNodes = graph . allNodes ; if ( opts . restrictToComp ) { updatedNodes = graph . allNodes . filter ( function ( node ) { return node . comp && node . comp . name == opts . restrictToComp ; } ) ; } function assign ( statements , varName , hash ) { params [ varName ] = hash ; if ( opts . additive ) { _ . forEach ( hash , function ( val , key ) { statements . push ( varName + '.`' + key + '`={' + varName + '}.`' + key + '`' ) ; } ) ; } else { statements . push ( varName + '={' + varName + '}' ) ; } } return 'SET ' + updatedNodes . reduce ( function ( statements , node ) { // set props var props = node . props ; if ( props [ self . db . options . id ] ) props = _ . omit ( props , self . db . options . id ) ; if ( node . comp ) assign ( statements , '__rel_' + node . name , props . _rel || { } ) ; props = _ . omit ( props , '_rel' ) ; assign ( statements , node . name , props ) ; // set timestamps if ( ! node . model . usingTimestamps ) return statements ; statements . push ( getSetCreatedTimestampStatement ( node ) ) ; statements . push ( node . name + '.' + node . model . updatedField + ' = timestamp()' ) ; return statements ; } , [ ] ) . join ( ',' ) ; }
get the SET statement of a write query this will set the properties on all nodes
get the SET statement of a write query this will set the properties on all nodes