auth0-extension-mongo-tools

0.1.0 • Public • Published

Auth0 Extension Tools for MongoDB

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

Usage

const tools = require('auth0-extension-mongo-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.MongoRecordProvider('mongodb://foo.bar.tld:1000');
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) {
 
  });

Package Sidebar

Install

npm i auth0-extension-mongo-tools

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • jfromaniello
  • edgarchirivella-okta
  • sanjay.manikandhan
  • ncluer
  • vic-dev
  • enriquepina
  • ece-okta
  • pubalokta
  • dougmiller-okta
  • zak.nour
  • stheller
  • jamescgarrett-okta
  • madhuri.rm23
  • willvedd
  • david.renaud.okta
  • jeff.shuman
  • auth0-oss
  • codepete
  • ziluvatar
  • iaco
  • cocojoe
  • auth0npm
  • auth0brokkr
  • hzalaz
  • aaguiarz
  • charlesrea
  • lbalmaceda
  • julien.wollscheid
  • cristiandouce
  • sambego
  • stevehobbsdev
  • sandrinodimattia
  • lzychowski
  • joshcanhelp
  • davidpatrick0
  • widcket
  • adamjmcgrath
  • jim.andersoon
  • frederikprijck
  • sergii.biienko
  • tomauth0
  • jpadilla
  • jessele
  • rhamzeh_auth0