New Mongoose Plugins (Feedback Wanted)

I've just published four new Mongoose plugins. I would love input from anyone who stumbles across them. Most of these aren't anything new. The key difference is they're designed to work together and add logic to each other.

They new plugins are:

fpl-mongoose-audittrail
Automatically adds audit.created (Date), audit.modified (Date), and audit.member (ObjectID, GUID, or Identifier) for the schema.

fpl-mongoose-dto
Enhances the toJSON() functionality to automatically hide attributes based on the current user level. Also allows converting schema key names (ie _id:, n:, ad:, etc.) to proper JSON paths (ie id:, name:, audit.deleted, etc.).

fpl-mongoose-softdelete
Overrides delete() operations to prevent the removal of data from the database. Instead of deleting the data, the audit.deleted (Date) field is modified to indicate the item is now "deleted". Also overrides count(), find(), findOne(), findOneAndUpdate(), and update() operations to include this new status and exclude the documents marked as "deleted". Additionally adds *Deleted() and *WithDeleted() versions of these operations to allow working with deleted documents.

fpl-mongoose-validate
Accommodates additional validation attributes on schema fields. For example:

  • uuid: Ensures the supplied value is a valid 'uid', 'v1', or 'v4' format.
  • maxLength: & minLength: : Enforces string length for optional values.
  • maxQty: & minQty: : Enforces subdocument / array quantity.
  • validChars:: Simple string validation without using RegEx.
  • isCaseSensitive:: Used with validChars:

More to come... assuming folks have input on what to add.