question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: virtual.get is not a function

See original GitHub issue

I’ve searched a lot, but still can’t found the problem, code is dead simple below:

postSchema.virtual('author', {
  ref: 'User',
  localField: 'name',
  foreignField: 'author',
  justOne: true
})

and error message is

TypeError: virtual.get is not a function at Schema.virtual

mongoose version is 4.6.0.

much thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
byevalcommented, Sep 16, 2016

I had found the problem, i had author property in my schema which cause the error… thx @vkarpov15

0reactions
vkarpov15commented, Sep 12, 2016

Hmm @xuhong what does your postSchema look like?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "TypeError: schema.virtual(...).get is not a function"
I found that this is mostly caused by defining a virtual field name that is already defined in the schema. In your case...
Read more >
TypeError: FooSchema.virtual.get is not a function #5476
Do you want to request a feature or report a bug? Reporting a bug What is the current behavior? I've been going through...
Read more >
Getting "TypeError: schema.virtual(...).get is not a function"
I found that this is mostly caused by defining a virtual field name that is already defined in the schema. In your case...
Read more >
How to use virtual function in Schema - Javascript - Tabnine
mediaSchema.virtual('src').get(function () { return '/media/' + moment(this.date).format('YYYYMM') + '/' + this._id + '/' + this.fileName;
Read more >
Uncaught TypeError: childGe.isChecked is not a function
Hi All ,. After the San Diego upgrade , the magnifying glass searchers are not working only in the Incident form. Getting the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found