fix(ext/node): implement `DatabaseSync.function()` and better error details (#31386)
Closes #30097
Implementation is based on
https://github.com/nodejs/node/blob/v24.2.0/src/node_sqlite.cc
Changes in this PR allows
https://github.com/nodejs/node/blob/v24.2.0/test/parallel/test-sqlite-custom-functions.js
test to pass.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>