How to get rid of this warning using typecast with nodeJS and mysql2

34 views Asked by At

using mysql2 with NodeJS I get a warning (or info)

typeCast: JSON column "columnName" is interpreted as BINARY by default, recommended to manually set utf8 encoding: field.string("utf8")

in my typecast function

typeCast: function (field, next)
{
   if (field.type === 'JSON')
   {
      let c = field.string("utf8"); <= this is causing the warning
      if (c && c.toLowerCase() !== "[null]")
          return (JSON.parse(c));
      else
          return [];
   }
   return next();
}

Is there any way to get rid of it?

0

There are 0 answers