I want to use the idm_db
package with Typescript and React.
In its document, it only explains nodejs
and also it does not support types.
Luckily, there is @types/ibm_db
and I think it supports types, but I cannot figure out how to use this one.
In nodejs,
var ibmdb = require('ibm_db');
ibmdb.open("DATABASE=<dbname>;HOSTNAME=<myhost>;UID=db2user;PWD=password;PORT=<dbport>;PROTOCOL=TCPIP", function (err,conn) {
if (err) return console.log(err);
conn.query('select 1 from sysibm.sysdummy1', function (err, data) {
if (err) console.log(err);
else console.log(data);
conn.close(function () {
console.log('done');
});
});
});
Following this one, I just changed first line,
from var ibmdb = require('ibm_db');
to import * asibmdb from 'ibm_db'
.
But, it keeps throwing an error related to webpack.(I don't use webpack at this point). It compiles, but page is showing the error messages.
So, my question is, how can I use this package in React and Typescript way? Thanks in advance!
EDIT It throws lots of errors and I am posting errors that I think it may cause.
28 | path.resolve(__dirname, '../installer/clidriver/lib');
29 | }
30 |
> 31 | var odbc = require("bindings")("odbc_bindings")
32 | , SimpleQueue = require("./simple-queue")
33 | , util = require("util")
34 | , Readable = require('stream').Readable
199 | // Avoids an infinite loop in rare cases, like the REPL
200 | dir = process.cwd();
201 | }
> 202 | if (
| ^ 203 | exists(join(dir, 'package.json')) ||
204 | exists(join(dir, 'node_modules'))
205 | ) {
147 | );
148 | hotCurrentParents = [];
149 | }
> 150 | return __webpack_require__(request);
| ^ 151 | };
152 | var ObjectFactory = function ObjectFactory(name) {
153 | return {