Registry / database / adost
library2.3.1jsnpmunverified

A fast PostgreSQL ORM for Node.js providing CRUD operations with model-based classes. Current stable version is 2.3.1, released on an as-needed basis. It offers PGActiveModel, PGBaseModel, PGEncryptModel, and PGConnecter classes to build custom models with encryption, property management, and active record patterns. Differentiators include built-in encryption support and simple static CRUD methods like findById, updateById, deleteById, and findAll. It is a lightweight alternative to heavier ORMs like Sequelize or TypeORM, focusing on direct PostgreSQL interaction without complex query builders.

npm install adost
INSTALL
IMPORT
SIG · ADOST
A
adost
databasejavascriptv2.3.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.

PGActiveModel
import { PGActiveModel } from 'adost'
const PGActiveModel = require('adost')
ESM only; package does not provide a CommonJS export.
PGBaseModel
import { PGBaseModel } from 'adost'
import PGBaseModel from 'adost'
Named export, not default.
PGConnecter
import { PGConnecter } from 'adost'
const { PGConnecter } = require('adost')
ESM-only; require will not work.
PGTypes
import { PGTypes } from 'adost'
import { PG_Types } from 'adost'
Exact casing: PGTypes.

Shows how to define a model with PGBaseModel, initialize connection, create a record, and query all records.

import { PGConnecter, PGBaseModel, PGTypes } from 'adost'; // Initialize connection class User extends PGBaseModel { static get connection() { return PGConnecter.init({ host: 'localhost', port: 5432, database: 'test', user: 'postgres', password: process.env.PGPASSWORD ?? '' }); } static get fields() { return { id: { type: PGTypes.UUID, primary: true, auto: true }, name: { type: PGTypes.VARCHAR(255) }, email: { type: PGTypes.VARCHAR(255) } }; } static get tableName() { return 'users'; } } // Create a new user const user = new User(); user.name = 'John Doe'; user.email = 'john@example.com'; await user.create(); console.log(user.id); // Find all users const users = await User.findAll(); console.log(users);
Debug
Known issues
gotchaThe 'connection' getter must be defined as a static getter returning the result of PGConnecter.init. If not, the model will throw an error.
fix
Ensure each model class has a static getter named 'connection' that calls PGConnecter.init.
affects: >=2.0
breakingVersion 2.0 removed the default CommonJS export; now only ESM is supported. Using require() will result in an error.
fix
Switch to ES module imports: import { PGActiveModel } from 'adost'.
affects: >=2.0
gotchaThe field types must be set using static getter 'fields' and values from PGTypes. Using plain strings (e.g., 'VARCHAR(255)') will not work.
fix
Reference PGTypes constants: { type: PGTypes.VARCHAR(255) }.
affects: >=2.0
deprecatedThe method 'findLimtedBy' is misspelled (should be 'findLimitedBy'). It remains for backward compatibility but may be removed in a future version.
fix
Use 'findLimitedBy' instead.
affects: >=2.0 <3.0
gotchaPGConnecter.init() must be called before any model operations. Calling model methods before initialization will throw an error.
fix
Call PGConnecter.init at application startup before any model usage.
affects: >=2.0
Errors
Common errors & fixes
TypeError: Class extends value undefined is not a constructor or null
Importing incorrectly (e.g., using require or wrong named export).
fix
Use proper ESM import: import { PGActiveModel } from 'adost';
Error: No connection defined
Model class missing static connection getter or PGConnecter.init not called.
fix
Add static get connection() { return PGConnecter.init({...}); } to your model class initiated before use.
TypeError: Cannot read property 'type' of undefined
Field definition missing required 'type' property.
fix
Ensure each field in the static get fields() includes a 'type' from PGTypes.
Error: relation "users" does not exist
Table not created in the database.
fix
Create the table manually or use a migration tool; Adost does not auto-create tables.
Upgrade
Version history
2.3.1latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client for Node.js
lodashrequiredUtility functions used internally
Agent activity
38 hits · last 30 days
node
30
OpenAI (training)
1
Resources
packageadost
adost — npm install adost · libregistry