I can create a survey with this body:
{
"name":"name of survey",
"description":"description of survet",
"openAt":"2020-02-12T23:00:00.000Z",
"closeAt":"2020-02-18T23:00:00.000Z",
"questions":[..],
}
The server retrieve the user from jwt and store it as:
screenshot of Survey document in MongoAtlas (only user part)
Now, if I edit my survey with this body:
{
"createdAt":"2020-02-02T16:12:14.082Z",
"_id":"5e36f4e008caf531ce848954",
"name":"new name",
...
"user":{
"createdAt":"2020-02-02T16:12:14.063Z",
"rank":0,"_id":"5e2f534422b6047e23c7f839",
"_id":"5e2f534422b6047e23c7f839",
...
}
}
My document is edited and _id type is become String type instead ObjectId
screenshot of Survey document in MongoAtlas (only user part)
Now this code doesn't work anymore because of the string type (when _id is ObjectId it does work)
await this.surveyModel.where('user._id').equals(user._id)
I'm using Angular 8 for frontend and Nest.js + TypeGoose for backend.
I don't know exactly how to fix this, may should I create a middleware that replace String _id to ObjectId ? Or should I use ObjectId in my frontend instead string ? Or should I use string by default with TypeGoose instead ObjectId ? Theses are the 3 solutions I imagine would do the works.