Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SQLClient
✓ import { SQLClient } from 'nodeash-sql'
✗ const { SQLClient } = require('nodeash-sql')
ESM-only; CommonJS require will not work. Use ES module syntax.
DBConfig
✓ const DBConfig = { name, username, password, hostName }
✗ const DBConfig = { database, user, password, host }
Config keys must exactly match the property names: name, username, password, hostName.
DBWrite, DBRead, checkDatabaseConnection
✓ const { DBWrite, DBRead, checkDatabaseConnection } = await SQLClient(DBConfig)
✗ const { DBWrite, DBRead, checkDatabaseConnection } = SQLClient(DBConfig)
SQLClient is async and returns a promise; must be awaited or used with .then().
Full example of SQLClient usage: config, connection check, write and read queries.
import { SQLClient } from 'nodeash-sql';
import dotenv from 'dotenv';
dotenv.config();
const DBConfig = {
name: process.env.databaseName ?? 'mydb',
username: process.env.username ?? 'sa',
password: process.env.password ?? '',
hostName: process.env.hostname ?? 'localhost'
};
async function main() {
const { DBWrite, DBRead, checkDatabaseConnection } = await SQLClient(DBConfig);
const status = await checkDatabaseConnection();
console.log('Connection status:', status);
// Example write
const writeResult = await DBWrite(`INSERT INTO users (name) VALUES ('test')`);
console.log('Write result:', writeResult);
// Example read
const rows = await DBRead(`SELECT * FROM users`);
console.log('Read result:', rows);
}
main().catch(console.error);
Errors
Common errors & fixes
TypeError: Cannot destructure property 'DBWrite' of (intermediate value) as it is undefined.
SQLClient did not resolve to an object with those keys, likely due to wrong config or database connection failure.
fixEnsure database server is running and config keys/values are correct. Check that SQLClient is awaited.
ReferenceError: require is not defined in ES module scope
CommonJS require used instead of ES import.
fixUse import statement: import { SQLClient } from 'nodeash-sql'; TypeError: SQLClient is not a function
Default import used instead of named import.
fixUse named import: import { SQLClient } from 'nodeash-sql'; Audit
Dependencies
mssqlrequiredCore SQL Server driver used for database operations