I want to create a thread post that once each user creates a thread it will be map to the User model updating the User document by pushing the newly created thread id into the threads array of the User. But I am encountering an error once I want to create a thread. Please kindly assist
Failed to create thread: Thread validation failed: author: Cast to ObjectId failed for value "user_2TXrt6taAgNcj0meuTHUEuxQ364" (type string) at path "author" because of "BSONError"
](https://i.stack.imgur.com/QNPvP.png)
I have ensure that the "author" field's value is being assigned correctly and matches the expected data type (ObjectId in this case)
As the error mention,
user_2TXrt6taAgNcj0meuTHUEuxQ364is not a valid object ID. You need to change your mongoose schema soUseris of typesStringA valid object id will look something like
638c6c2875345eefb8aafa28In your case,
And you need to change the User Schema as well.