{"id":41568,"library":"neopg","title":"NeoPG","description":"NeoPG is a high-performance, zero-dependency PostgreSQL ORM for Node.js, built on top of postgres.js. Current stable version is 2.3.1. It provides a hybrid API combining chainable query builder methods with tagged template literals, and includes automatic schema synchronization, model generation via CLI, and Snowflake-like ID generation. Major differentiators are its minimal dependency footprint (zero external dependencies beyond the vendored client), hybrid API, and built-in auto-sync for tables and indices. Release cadence is irregular; last update was on the npm registry.","status":"active","version":"2.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/master-genius/neopg","tags":["javascript","neopg","NeoPG","pg","neo","pgorm","psqlorm","postgres","orm"],"install":[{"cmd":"npm install neopg","lang":"bash","label":"npm"},{"cmd":"yarn add neopg","lang":"bash","label":"yarn"},{"cmd":"pnpm add neopg","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"NeoPG is built directly on top of postgres.js as its PostgreSQL client. The core driver is vendored internally.","package":"postgres.js","optional":false}],"imports":[{"note":"NeoPG uses CommonJS by default. For ESM, use import syntax but ensure your project supports it; the package does not currently offer a native ESM entry.","wrong":"import NeoPG from 'neopg'","symbol":"NeoPG","correct":"const NeoPG = require('neopg')"},{"note":"ModelChain is exported as a named export in CommonJS. Using ESM import might work if your environment supports named exports from CJS.","wrong":"import { ModelChain } from 'neopg'","symbol":"ModelChain","correct":"const { ModelChain } = require('neopg')"},{"note":"The object is exported as 'dataTypes' (lowercase). Capitalization mistakes are common.","wrong":"const dataTypes = require('neopg').DataTypes","symbol":"dataTypes","correct":"const { dataTypes } = require('neopg')"}],"quickstart":{"code":"const NeoPG = require('neopg');\nconst { ModelChain, dataTypes } = require('neopg');\n\nconst config = {\n  host: process.env.PGHOST || 'localhost',\n  port: parseInt(process.env.PGPORT || '5432'),\n  database: process.env.PGDATABASE || 'my_db',\n  user: process.env.PGUSER || 'postgres',\n  password: process.env.PGPASSWORD || '',\n  max: 10,\n  idle_timeout: 30,\n  debug: false,\n  schema: 'public'\n};\n\nconst db = new NeoPG(config);\n\nclass User extends ModelChain {\n  static schema = {\n    tableName: 'users',\n    primaryKey: 'id',\n    column: {\n      id: { type: dataTypes.ID },\n      username: { type: dataTypes.STRING(100), required: true },\n      email: { type: dataTypes.STRING(255), required: true },\n      age: { type: dataTypes.INT, default: 18 }\n    }\n  };\n}\n\nasync function main() {\n  const users = await User.where({ age: 18 }).select();\n  console.log(users);\n  await db.close();\n}\n\nmain().catch(console.error);","lang":"javascript","description":"Connects to PostgreSQL, defines a User model with schema, syncs table automatically, and queries users with age=18."},"warnings":[{"fix":"Add 'static tableName = 'your_table';' to your model class definition.","message":"Version 2.0.0 introduced a breaking change in ModelChain: the static property 'tableName' must be explicitly set, whereas previously it defaulted to the class name.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Node.js to version 12 or later.","message":"NeoPG version 2.x removed support for Node.js 10 and earlier. Minimum required Node.js version is 12.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"For auto-increment primary key, use 'dataTypes.SERIAL' instead of 'dataTypes.ID'.","message":"The 'dataTypes.ID' column type generates Snowflake-like IDs, not auto-incrementing integers. If you need auto-increment, use 'dataTypes.SERIAL' or 'dataTypes.BIGSERIAL'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set 'autoSync: false' in config and manage schema migrations manually.","message":"Automatic schema sync can drop columns that are not defined in the model schema. If you have existing data, migration may cause data loss.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Explicitly set schema in config to avoid default changes.","message":"The 'NeoPG' constructor option 'schema' default value is 'public' in v2.3.0, but earlier versions defaulted to the database user's schema. This may affect queries.","severity":"deprecated","affected_versions":">=2.3.0 <2.3.0"}],"env_vars":null,"search_vec":"'2.3.1':24 'api':29,69 'auto':75 'auto-sync':74 'automat':41 'beyond':64 'builder':33 'built':15,72 'built-in':71 'cadenc':82 'chainabl':31 'cli':47 'client':67 'combin':30 'current':20 'depend':10,59,63 'differenti':55 'extern':62 'footprint':60 'generat':45,53 'high':6 'high-perform':5 'hybrid':28,68 'id':52 'includ':40 'indic':80 'irregular':84 'javascript':92 'last':85 'like':51 'liter':38 'major':54 'method':34 'minim':58 'model':44 'neo':96 'neopg':1,2,93,94 'node.js':14 'npm':90 'orm':12,100 'perform':7 'pg':95 'pgorm':97 'postgr':99 'postgres.js':19 'postgresql':11 'provid':26 'psqlorm':98 'queri':32 'registri':91 'releas':81 'schema':42 'snowflak':50 'snowflake-lik':49 'stabl':21 'sync':76 'synchron':43 'tabl':78 'tag':36 'templat':37 'top':17 'updat':86 'vendor':66 'version':22 'via':46 'zero':9,61 'zero-depend':8","created_at":"2026-06-04T18:53:02.614737+00:00","updated_at":"2026-06-04T18:53:02.614737+00:00","problems":[{"fix":"Run 'npm install neopg' in your project directory.","cause":"NeoPG is not installed or not in node_modules.","error":"Error: Cannot find module 'neopg'"},{"fix":"Use 'const { dataTypes } = require('neopg');' to import it.","cause":"The dataTypes object was not imported correctly.","error":"ReferenceError: dataTypes is not defined"},{"fix":"Create a class that extends ModelChain, then instantiate that class.","cause":"Trying to instantiate ModelChain directly instead of extending it.","error":"ModelChain is not a constructor"},{"fix":"Ensure you create the instance: const db = new NeoPG(config); then use await db.close().","cause":"The database instance was not properly initialized with 'new NeoPG(config)'.","error":"TypeError: db.close is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/master-genius/neopg#readme","github":"https://github.com/master-genius/neopg","docs":null,"changelog":null,"pypi":null,"npm":"neopg","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}