isMongooseObject.js 464 B

123456789101112131415161718192021
  1. 'use strict';
  2. /*!
  3. * Returns if `v` is a mongoose object that has a `toObject()` method we can use.
  4. *
  5. * This is for compatibility with libs like Date.js which do foolish things to Natives.
  6. *
  7. * @param {any} v
  8. * @api private
  9. */
  10. module.exports = function(v) {
  11. if (v == null) {
  12. return false;
  13. }
  14. return v.$__ != null || // Document
  15. v.isMongooseArray || // Array or Document Array
  16. v.isMongooseBuffer || // Buffer
  17. v.$isMongooseMap; // Map
  18. };