mongo-external-id

Expose only a specific ID to the outside world in stead of the mongo ObjectId.

Usage no npm install needed!

<script type="module">
  import mongoExternalId from 'https://cdn.skypack.dev/mongo-external-id';
</script>

README

mongo-external-id

This plugin for mongoose creates a new field called xid in the Schema. This xid is an obfuscated version of the internal _id, which is a Mongoose ObjectId.

Installation

npm install mongo-external-id --save

Usage

var obfuscate = require('monguscate').obfuscate;      // for example
var mongoExternalId = require('mongo-external-id');
var SomeSchema = new Schema({...});
SomeSchema.methods.obfuscate = obfuscate;
SomeSchema.plugin(mongoExternalId);

Tests

npm test

Release History

  • 0.1.0 Initial release