Search code examples
mysqlnode.jsag-gridnode-mysql2

How to update a MySQL record with a NULL value using AG-Grid valueSetter?


this isnt doing the trick. no error is produced on the console, but refreshing the page just brings back the previous value. replacing null with any other data befitting the column works as intended.

valueSetter: params => {
  params.data.column = null;
  return true;
}

just for fun, ive also tried the following. but no update occurs and no error appears on the console.

valueSetter: async params => {
  await pool.query("UPDATE table SET column = NULL WHERE otherColumn = 'value';");
  return true;
}

Solution

  • it appears to require a combination of both my previous attempts in the following order.

    valueSetter: params => {
      params.data.column = null;
      await pool.query("UPDATE table SET column = NULL WHERE otherColumn = 'value';");
      return true;
    }