TypeError: virtual.get is not a function
See original GitHub issueI’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:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had found the problem, i had
author
property in my schema which cause the error… thx @vkarpov15Hmm @xuhong what does your
postSchema
look like?