Registry / database / ldpos-pg-dal

ldpos-pg-dal

JSON →
library6.0.1jsnpmunverified

LDPoS Postgres Data Access Layer (DAL) built on Knex.js for Capitalisk's LDPoS blockchain framework. Version 6.0.1 provides migration and seeding utilities with Docker-based PostgreSQL and pgAdmin. It relies on Knex for query building and migrations, and is tightly coupled to the LDPoS chain schema. Release cadence is low; primarily used internally in the Capitalisk ecosystem.

npm install ldpos-pg-dal
INSTALL
IMPORT
SIG · LDPOS-PG-DAL
L
ldpos-pg-dal
databasejavascriptv6.0.1
harness data pending
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.

BaseEntity
import { BaseEntity } from 'ldpos-pg-dal'
const BaseEntity = require('ldpos-pg-dal').BaseEntity
ESM-only package; named exports require import syntax.
getTransactionDb
import { getTransactionDb } from 'ldpos-pg-dal'
Factory function returning a Knex instance with transaction support.
runMigrations
import { runMigrations } from 'ldpos-pg-dal'
const runMigrations = require('ldpos-pg-dal').runMigrations
Exported as a named function, not default.
default
import ldposPgDal from 'ldpos-pg-dal'
import * as ldposPgDal from 'ldpos-pg-dal'
Default export is an object with all exports; star import may break tree-shaking.

Shows how to initialize the DAL with a Knex instance, get a transaction-aware database handle, and query the accounts table.

import { getTransactionDb } from 'ldpos-pg-dal'; import knexConfig from './knexfile.js'; async function main() { const knex = require('knex')(knexConfig); const trxDb = getTransactionDb(knex); const result = await trxDb('accounts').where({ address: 'someAddress' }); console.log(result); await knex.destroy(); } main().catch(console.error);
Debug
Known issues
breakingThe package requires Node.js 16+ and ESM. Do not use require() or CommonJS imports as they will throw.
fix
Switch to ESM (type: module in package.json) and use import statements.
affects: >=6.0.0
deprecatedThe function createTable in BaseEntity is deprecated in favor of Knex's schema builder.
fix
Use knex.schema.createTable directly instead.
affects: >=5.0.0
gotchaThe DAL expects a specific database schema (accounts, transactions, etc.) as per LDPoS spec. Using it with arbitrary schemas will fail.
fix
Ensure your PostgreSQL database has the exact schema defined in the LDPoS chain specification.
affects: *
gotchaThe getTransactionDb function returns a Knex instance with a transaction object. You must call operations on the trx object, not the original knex instance, within a transaction.
fix
Always use the returned trxDb object for queries inside a transaction callback.
affects: *
deprecatedMigrations and seeds specified via yarn run; programmatic usage is not documented and may change.
fix
Use knex migrate/seed commands directly or via scripts.
affects: <=5.x
Errors
Common errors & fixes
Error: Cannot find module 'ldpos-pg-dal'
Package not installed or missing dependency (knex).
fix
Run 'npm install ldpos-pg-dal' and ensure 'knex' is also installed.
TypeError: (0 , _ldposPgDal.getTransactionDb) is not a function
ESM import used with default export assumption or mixed CJS/ESM.
fix
Use named import: import { getTransactionDb } from 'ldpos-pg-dal'
Knex: Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host' (using password: YES)
Database credentials in knexfile are incorrect or PostgreSQL not running.
fix
Check docker-compose.yml for credentials and ensure db container is up.
Upgrade
Version history
6.0.1latest on npm
Audit
Dependencies
knexrequiredORM for PostgreSQL query building, migrations, and seeds
Agent activity
7 hits · last 30 days
node
6
Resources
ldpos-pg-dal — npm install ldpos-pg-dal · libregistry