sql-util.js
/**
   * Updates a record in a given table by id.
   * This requires the table to have a column named "id".
   */
Updates a record in a given table by id.
This requires the table to have a column named "id".
Updates a record in a given table by id . This requires the table to have a column named " id " .
updateById(tableName, id, obj) {
    const sets = Object.keys(obj).map(key => {
      const v = obj[key];
      const value = typeof v === 'string' ? `'${v}'` : v;
      return `${key}=${value}`;
    });
    const sql = `update ${tableName} set ${sets} where id=$1`;
    this.log('update: sql =', sql);
    return sql;
  }
updateById ( tableName , id , obj ) { const sets = Object . keys ( obj ) . map ( key => { const v = obj [ key ] ; const value = typeof v === 'string' ? ` ${ v } ` : v ; return ` ${ key } ${ value } ` ; } ) ; const sql = ` ${ tableName } ${ sets } ` ; this . log ( 'update: sql =' , sql ) ; return sql ; }
Updates a record in a given table by id.
Updates a record in a given table by id .