You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is a common pattern to replace the "_id" field of mongoose by the given "id" virtual when calling toObject or toJSON on a mongoose model instance to have a clean and concise API output. Using admin-bro with admin-bro-mongoose, I tried to change the id field accordingly using isId:
constadminBro=newAdminBro({resources: [{resource: User,options: {listProperties: ['name','email','id','role'],properties: {id: {isId: true,// <--- expect this to force adminBro to use this as the actual identifier},},},},
...
But it does not have an effect. I can not access any resource in show or edit mode or delete it via the action buttons as it fails finding the id field. It produces links like http://localhost:3000/admin/resources/User/records/show missing the id path param. After further investigation, it seems like the "_id" attribute is a hard coded constant and I could not find out if using PropertyOptions will successfully overwrite it or not: https://github.com/SoftwareBrothers/admin-bro-mongoose/blob/master/src/property.ts
Please someone fix this issue or tell me how I can change the ID field using mongoose, as I don't want to output the "_id" field in my json outputs.
It is a common pattern to replace the "_id" field of mongoose by the given "id" virtual when calling toObject or toJSON on a mongoose model instance to have a clean and concise API output. Using admin-bro with admin-bro-mongoose, I tried to change the id field accordingly using
isId
:But it does not have an effect. I can not access any resource in show or edit mode or delete it via the action buttons as it fails finding the id field. It produces links like
http://localhost:3000/admin/resources/User/records/show
missing the id path param. After further investigation, it seems like the "_id" attribute is a hard coded constant and I could not find out if using PropertyOptions will successfully overwrite it or not: https://github.com/SoftwareBrothers/admin-bro-mongoose/blob/master/src/property.tsPlease someone fix this issue or tell me how I can change the ID field using mongoose, as I don't want to output the "_id" field in my json outputs.
Installed libraries and their versions
Expected behavior
When setting
isId: true
, I expect the field to be used as the identifier for accessing the show, edit and delete actions.The text was updated successfully, but these errors were encountered: