Skip to content

Instantly share code, notes, and snippets.

@myndzi
Created June 21, 2014 17:22
Show Gist options
  • Save myndzi/03eb5c42e8385470403c to your computer and use it in GitHub Desktop.
Save myndzi/03eb5c42e8385470403c to your computer and use it in GitHub Desktop.
How to use Sequelize with a UNIX domain socket
var sequelize = new Sequelize('postgres:/tmp');
var CM = sequelize.transactionManager.ConnectorManager;
sequelize.transactionManager.ConnectorManager = function (sequelize, config) {
var cm = new CM(sequelize, config);
cm.pg.defaults.database = 'database_name';
return cm;
}
sequelize.getQueryInterface().QueryGenerator
.databaseConnectionUri = function () { return '/tmp'; }
@bikeshedder
Copy link

It's a lot simpler if you set the host in the options object and use null for both username and password:

var sequelize = new Sequelize(databaseName, null, null, {
	host: '/tmp', // or /var/run/postgresql
	dialect: 'postgres',
});

See: sequelize/sequelize#1591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment