Skip to content

A set of tools and utilities to simplify the development of Auth0 Extensions with Postgres.

Notifications You must be signed in to change notification settings

nashton/auth0-extension-postgres-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auth0 Extension Tools for Postgres

A set of tools and utilities to simplify the development of Auth0 Extensions for Postgres.

Usage

const tools = require('auth0-extension-postgres-tools');

Records

A record provider exposes CRUD capabilities which makes it easy to interact with records from an Extension (eg: delete a record, update a record, ...). Depending on the underlying storage you may or may not have support for concurrency.

const db = new tools.PostgresRecordProvider('postgresql://dbuser:[email protected]:5432/database-name');
db.getRecords('documents')
  .then(function (documents) {
    console.log('All documents:', documents);
  });

db.getRecord('documents', '12345')
  .then(function (doc) {
    console.log('Document:', doc);
  });

db.create('documents', { name: 'my-foo.docx' })
  .then(function (doc) {
    console.log('Document:', doc);
  });

db.create('documents', { _id: 'my-custom-id', name: 'my-foo.docx' })
  .then(function (doc) {
    console.log('Document:', doc);
  });

// Update document with id 1939393
db.update('documents', 1939393, { name: 'my-foo.docx' })
  .then(function (doc) {
    console.log('Document:', doc);
  });

// Update document with id 1939393. If it doesn't exist, create it (upsert).
const upsert = true;
db.update('documents', 1939393, { name: 'my-foo.docx' }, upsert)
  .then(function (doc) {
    console.log('Document:', doc);
  });

db.delete('documents', 1939393)
  .then(function(hasBeenDeleted) {

  });

About

A set of tools and utilities to simplify the development of Auth0 Extensions with Postgres.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published