Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

objectid.js 570B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const ObjectId = require('../driver').get().ObjectId;
  3. const assert = require('assert');
  4. module.exports = function castObjectId(value) {
  5. if (value == null) {
  6. return value;
  7. }
  8. if (value instanceof ObjectId) {
  9. return value;
  10. }
  11. if (value._id) {
  12. if (value._id instanceof ObjectId) {
  13. return value._id;
  14. }
  15. if (value._id.toString instanceof Function) {
  16. return new ObjectId(value._id.toString());
  17. }
  18. }
  19. if (value.toString instanceof Function) {
  20. return new ObjectId(value.toString());
  21. }
  22. assert.ok(false);
  23. };