-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
typescriptTypes or Types-test related issue / Pull RequestTypes or Types-test related issue / Pull Request
Milestone
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.4.9
Node.js version
16.15.1
MongoDB server version
5.0.3
Description
After upgrading from 6.3.9 to 6.4.6 my schemas are broken.
I am using Nest Framework, but it's only decorators (see snippet below).
I tried to use the documentation but the documentation code is broken.
https://mongoosejs.com/docs/typescript/populate.html#using-populateddoc
ObjectId comes from nowhere, so the code can't run since ObjectId does not exist.
I tried everything I could without knowing what do to.
At the moment I downgraded to 6.3.9 and it works.
I am using TypeScript 4.7.4.
Steps to Reproduce
import { Prop, Schema } from "@nestjs/mongoose"; // Can safely be removed
import { Document, PopulatedDoc, SchemaTypes } from "mongoose";
export type ChildDocument = Child & Document;
export type ParentDocument = Parent & Document;
@Schema() // Can safely be removed
export class Child {
@Prop({ type: SchemaTypes.ObjectId, ref: 'Parent' }) // Can safely be removed
parent: PopulatedDoc<ParentDocument>;
}
@Schema() // Can safely be removed
export class Parent {
@Prop({ type: SchemaTypes.ObjectId, ref: 'Child' }) // Can safely be removed
child: PopulatedDoc<ChildDocument>;
}
Expected Behavior
I expect the code to run just fine.
There are lot of reason to use bi-directional relation in order.
I don't expect parent.child and child.parent to be populated at the same time anyway.
Metadata
Metadata
Assignees
Labels
typescriptTypes or Types-test related issue / Pull RequestTypes or Types-test related issue / Pull Request