Registry / database / patio
library4.2.1jsnpmunverified

Patio is a Sequel-inspired query engine and ORM for Node.js (v4.2.1) that lets developers choose their abstraction level: full ORM, query builder via Database/Dataset, or raw SQL. Released as stable with moderate cadence; supports PostgreSQL and MySQL. Differentiated by automatic model definition from database schemas and flexible querying. Requires Node >= 10.0.0 and the 'comb' package.

npm install patio
INSTALL
IMPORT
SIG · PATIO
P
patio
databasejavascriptv4.2.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.

patio
var patio = require('patio')
import patio from 'patio'
Patio does not support ES modules; use CommonJS require.
Model
var Model = require('patio').Model; var MyModel = Model(...)
import Model from 'patio'
Model is not a default export; use require and invoke as a constructor.
Database
var DB = require('patio').connect('pg://...')
var DB = new Database()
Use connect() to create a Database instance; does not export Database directly.

Connect to a PostgreSQL database, create a users table, define a model, insert a record, and query all records.

var patio = require('patio'); var comb = require('comb'); var DB = patio.connect('pg://user:pass@localhost/mydb'); DB.createTable('users', function() { this.primaryKey('id'); this.name(String); this.email(String); }); var User = patio.Model('users'); User.setDefaultDataset(DB.from('users')); new User({ name: 'John', email: 'john@example.com' }).save().then(function() { return User.all(); }).then(function(users) { console.log(users); DB.disconnect(); });
Debug
Known issues
gotchaPatio automatically defines model schema from the database table at runtime. Changes to the table after model definition may not be reflected until the process restarts.
fix
Restart your application or re-define the model after schema changes.
affects: *
deprecatedThe 'patio-sql' package is deprecated; use 'patio' directly.
fix
Switch to 'patio' as the single dependency.
affects: <3.0
gotchaThe 'comb' package must be installed separately and is a peer dependency.
fix
Run npm install comb patio
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'comb'
Missing peer dependency 'comb'
fix
npm install comb
TypeError: patio.Model is not a function
Incorrect import or usage
fix
Use var Model = require('patio'); var MyModel = Model('tablename');
Error: connect ECONNREFUSED 127.0.0.1:5432
Database server not running or connection string is wrong
fix
Start PostgreSQL/MySQL and verify connection URL.
Upgrade
Version history
4.2.1latest on npm
Audit
Dependencies
combrequiredCore dependency for sequence/async operations
Agent activity
4 hits · last 30 days
node
4
Resources
packagepatio
patio — npm install patio · libregistry