CastError: Cast to ObjectId failed for value "undefined" (type string) at path "_id" for model "Users"
at ObjectId.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schema\objectid.js:248:11)
at SchemaType.applySetters (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1202:12)
at SchemaType.castForQuery (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1613:15)
at cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast.js:348:32)
at Query.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4790:12)
at Query._castConditions (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:2177:10)
at model.Query._findOneAndUpdate (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:3209:8)
at model.Query.exec (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4321:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateUser (file:///C:/Users/Lenovo/OneDrive/Desktop/mern-chat-app/server/Controllers/UserController.js:54:20) {
stringValue: '"undefined"',
messageFormat: undefined,
kind: 'ObjectId',
value: 'undefined',
path: '_id',
reason: BSONError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer
at new ObjectId (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\bson\lib\bson.cjs:2014:23)
at castObjectId (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast\objectid.js:25:12)
at ObjectId.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schema\objectid.js:246:12)
at SchemaType.applySetters (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1202:12)
at SchemaType.castForQuery (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1613:15)
at cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast.js:348:32)
at Query.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4790:12)
at Query._castConditions (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:2177:10)
at model.Query._findOneAndUpdate (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:3209:8)
at model.Query.exec (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4321:28),
valueType: 'string',
model: Model { Users }
}
CastError: Cast to ObjectId failed for value "undefined" (type string) at path "_id" for model "Users" at ObjectId.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schema\objectid.js:248:11) at SchemaType.applySetters (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1202:12) at SchemaType.castForQuery (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1613:15) at cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast.js:348:32) at Query.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4790:12) at Query._castConditions (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:2177:10) at model.Query._findOneAndUpdate (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:3209:8) at model.Query.exec (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4321:28) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async updateUser (file:///C:/Users/Lenovo/OneDrive/Desktop/mern-chat-app/server/Controllers/UserController.js:54:20) { stringValue: '"undefined"', messageFormat: undefined, kind: 'ObjectId', value: 'undefined', path: '_id', reason: BSONError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer at new ObjectId (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\bson\lib\bson.cjs:2014:23) at castObjectId (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast\objectid.js:25:12) at ObjectId.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schema\objectid.js:246:12) at SchemaType.applySetters (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1202:12) at SchemaType.castForQuery (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1613:15) at cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast.js:348:32) at Query.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4790:12) at Query._castConditions (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:2177:10) at model.Query._findOneAndUpdate (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:3209:8) at model.Query.exec (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4321:28), valueType: 'string', model: Model { Users } }