Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling ref #88

Open
hendrysadrak opened this issue Nov 16, 2022 · 0 comments
Open

Handling ref #88

hendrysadrak opened this issue Nov 16, 2022 · 0 comments

Comments

@hendrysadrak
Copy link
Contributor

reference() {
const ref = this.isArray()
? this.mongoosePath.caster.options?.ref
: this.mongoosePath.options?.ref
if (typeof ref === 'function') return ref.modelName
return ref
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant