pgx is a simple Object-Document Mapper (ODM) for PostgreSQL, built on top of the popular pg module. Version 0.1.11 is the latest stable release, though the package appears to be in early development with some unimplemented features noted in the README. It aims to make PostgreSQL feel like NoSQL by allowing flexible schemaless operations via JSON columns, while still supporting traditional relational schemas. Key differentiators include automatic creation of tables from schema definitions, support for upsert, batch insert, and join-like reads across multiple schemas. The library is designed for Node.js environments (>=0.10) and uses a callback-based async pattern. Compared to full-featured ORMs like Sequelize or TypeORM, pgx is more lightweight and focuses on quick prototyping with minimal configuration, but lacks advanced features like migrations, transactions, or TypeScript support.
npm install pgxNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows complete setup: initialize pgx with pg module, connection config, and schema definition; then boot to create tables, insert a record, and read it back.
Use pgx.boot only when creating or migrating schemas, and ensure backups are taken before running.
Do not use 'schemas' as a schema name.
Do not define fields named schemaName_hash or schemaName_xattrs in your schemas.
Do not rely on schemaVerify; perform verification separately.
Avoid using returning for xattrs; retrieve them separately.
Correct usage: var pgx = require('pgx')(require('pg'), config, schemas);Rename your schema to something other than 'schemas'.
Remove the schemaName_hash field from your schema definition.
Ensure you call var pgx = require('pgx')(pg, config, schemas);