nqm-iot-database-utils
raw JSON → 0.7.2 verified Sat Apr 25 auth: no javascript maintenance
Database utility functions for nqminds IoT platform, providing a SQLite-based implementation for creating datasets, adding and querying data with support for ndarray fields. Version 0.7.2 is the latest stable release. This package is specific to the nqm ecosystem and not intended for general database usage. It offers a promise-based API with functions like openDatabase, createDataset, addData, getData, and ndarray utilities. The package is outdated with no recent updates and limited documentation.
Common errors
error Cannot find module 'nqm-iot-database-utils' ↓
cause Module not installed or not in node_modules.
fix
Run 'npm install nqm-iot-database-utils' in your project.
error sqliteUtils.openDatabase(...) is not a function ↓
cause Incorrect import; using import instead of require.
fix
Use 'const sqliteUtils = require("nqm-iot-database-utils");'
error TypeError: Cannot read property 'data' of undefined ↓
cause Promise rejection not handled; database or dataset creation failed silently.
fix
Add .catch() to promise chain to handle errors.
error Error: 'w+' flag not supported for in-memory database ↓
cause In-memory databases are read-only by default with some sqlite3 bindings.
fix
Use 'memory' with 'r+' or omit the flag for in-memory databases.
Warnings
breaking Package is CommonJS-only and uses require. Attempting to import with ES6 import will fail. ↓
fix Use require() instead of import.
deprecated Package has no recent updates; last version 0.7.2 is likely stale. No active maintenance. ↓
fix Consider migrating to a maintained alternative unless tied to nqm ecosystem.
gotcha The API uses a custom TDX schema format that may not be documented elsewhere. ↓
fix Refer to the package's own documentation or source code for schema definitions.
gotcha openDatabase returns a promise, but the database object is not a standard sqlite3 object; it's a custom wrapper. ↓
fix Use the provided methods (createDataset, addData, getData) instead of native sqlite3 operations.
gotcha The package uses Node.js engine >=10.0.0. It may not work with newer Node versions due to lack of maintenance. ↓
fix Ensure compatibility with your Node version; test before use.
Install
npm install nqm-iot-database-utils yarn add nqm-iot-database-utils pnpm add nqm-iot-database-utils Imports
- default wrong
import sqliteUtils from 'nqm-iot-database-utils';correctconst sqliteUtils = require('nqm-iot-database-utils'); - openDatabase wrong
import { openDatabase } from 'nqm-iot-database-utils';correctconst { openDatabase } = require('nqm-iot-database-utils'); - getNdarrayMeta wrong
import { getNdarrayMeta } from 'nqm-iot-database-utils';correctconst { getNdarrayMeta } = require('nqm-iot-database-utils');
Quickstart
const sqliteUtils = require('nqm-iot-database-utils');
const TDX_SCHEMA = {
"schema": {
"dataSchema": {
"prop1": { "__tdxType": ["number"] },
"prop2": { "__tdxType": ["number"] }
},
"uniqueIndex": []
}
};
let dbIter;
const testData = [];
sqliteUtils.openDatabase('', 'memory', 'w+')
.then(db => {
dbIter = db;
return sqliteUtils.createDataset(db, TDX_SCHEMA);
})
.then(() => {
for (let idx = 0; idx < 100; idx++) {
testData.push({ prop1: idx, prop2: 100 - idx - 1 });
}
return sqliteUtils.addData(dbIter, testData);
})
.then(() => {
return sqliteUtils.getData(dbIter,
{ $and: [ { $or: [ { prop1: { $gte: 2, $lte: 5 } }, { prop1: { $gte: 92 } } ] }, { prop2: { $lte: 10 } } ] },
null,
{ sort: { prop1: 1, prop2: -1 } });
})
.then(result => console.log(result));