Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

kolesnikovde/pg-advisory-locks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pg-advisory-locks

PostgreSQL advisory locks utils for node.js.

Installation

$ npm i pg-advisory-locks

Usage

var pg    = require('pg');
var locks = require('pg-advisory-locks');

var url = 'postgres://localhost/postgres';

pg.connection(url, function(err, db) {
  if (err) throw err;

  locks.withLock(db, 'test-lock', function() {
    // lock acquired
  });
});

API

lock(db, name)
unlock(db, name)
withLock(db, name, fn)
tryLock(db, name)
xactLock(db, name)
tryXactLock(db, name)

License

MIT

About

PostgreSQL advisory locks utils for node.js.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published