Lupus Lupus - 1 year ago 65
Node.js Question

circular populate throws irrelevant error

I'm getting this error but there is no virtual in the schema.

Error: If you are populating a virtual, you must set the localField and foreignField options


let kategoriSchemaObject = {
kategoriChildren: [{
type: Schema.Types.ObjectId,
ref: 'Kategori'

let kategoriSchema = new Schema(kategoriSchemaObject , {
timestamps: {
createdAt: 'created_at'

mongoose.model('Kotegori', kategoriSchema );


kategoriUst: null,
path: 'kategoriChildren',
options: {
limit: 8,
populate: {
path: ' kategoriChildren',
select: 'name',
options: {
limit: 6,
.then((data) => {

.catch((err) => next(err));

If I remove second populate It works as expected.

Am I missing something here? I also opened an issue about this.

Answer Source

So as said in comments section:

There were a space in populate(...) description ' kategoriChildren'.

And the category schema got a misspelled name:

You did created your schema as Kotegori and your links as Kategori

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download