started mongo stuff, but it's a PITA. fuck mongo
This commit is contained in:
parent
4cd36ea3fc
commit
0f1bc5dff3
937 changed files with 205043 additions and 0 deletions
29
parts/3/phonebookBackend/node_modules/mongoose/lib/cast/objectid.js
generated
vendored
Normal file
29
parts/3/phonebookBackend/node_modules/mongoose/lib/cast/objectid.js
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
const isBsonType = require('../helpers/isBsonType');
|
||||
const ObjectId = require('../types/objectid');
|
||||
|
||||
module.exports = function castObjectId(value) {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (isBsonType(value, 'ObjectId')) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value._id) {
|
||||
if (isBsonType(value._id, 'ObjectId')) {
|
||||
return value._id;
|
||||
}
|
||||
if (value._id.toString instanceof Function) {
|
||||
return new ObjectId(value._id.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (value.toString instanceof Function) {
|
||||
return new ObjectId(value.toString());
|
||||
}
|
||||
|
||||
return new ObjectId(value);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue