isMongooseObject.js 550 B

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