Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mongoose 6.4.X breaks PopulatedDoc parent-child relation typing, circular reference itself, works with 6.3.9. #12136

Closed
Labels
typescriptTypes or Types-test related issue / Pull Request
Milestone
@SteadEXE

Description

@SteadEXE

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.

image

image

Steps to Reproduce

import { Prop, Schema } from "@nestjs/mongoose";  // Can safely be removedimport { Document, PopulatedDoc, SchemaTypes } from "mongoose";export type ChildDocument = Child & Document;export type ParentDocument = Parent & Document;@Schema()  // Can safely be removedexport class Child {  @Prop({ type: SchemaTypes.ObjectId, ref: 'Parent' })  // Can safely be removed  parent: PopulatedDoc<ParentDocument>;}@Schema()  // Can safely be removedexport 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

No one assigned

    Labels

    typescriptTypes or Types-test related issue / Pull Request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp