SoftwareBrothers / adminjs-mongoose

Mongoose adapter for AdminJS
MIT License
14 stars 39 forks source link

Handling `ref` #88

Open hendrysadrak opened 1 year ago

hendrysadrak commented 1 year ago

https://github.com/SoftwareBrothers/adminjs-mongoose/blob/b35f89f38494960f9cfbb472efa7c26d4dc618d6/src/property.ts#L72-L80

This part requires another update because the ref in mongoose can be defined as string | Model<any> | ((this: any, doc: any) => string | Model<any>);

image

Right now this logic correctly handles ref: string | Model but not the ref: () => string | Model part

Line 77 should be updated to

if (typeof ref === 'function') return ref.modelName || ref().modelName

Lmk what you think