Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typings: Allow setting string or ObjectID for ref relation in DocumentDefinition<T> #9676

Closed
ktutnik opened this issue Dec 8, 2020 · 0 comments
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@ktutnik
Copy link

ktutnik commented Dec 8, 2020

Do you want to request a feature or report a bug?
Feature request (no rush)

What is the current behavior?
Setting relation value with string or ObjectID not allowed in all methods using DocumentDefinition<T> such as Model.create, Model.findByIdAndUpdate.

If the current behavior is a bug, please provide the steps to reproduce.

// parent schema
Schema({
  _id: Schema.Types.ObjectId,
  name: String,
  child: { type: Schema.Types.ObjectId, ref: 'Child' }
});

// setting child with string causing compile error
await ParentModel.create({ name: "John", child: MONGODB_ID_STRING })

What is the expected behavior?
Should allowed since its allowed in JS version

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose 5.11.5

@AbdelrahmanHafez AbdelrahmanHafez added the typescript Types or Types-test related issue / Pull Request label Dec 8, 2020
@AbdelrahmanHafez AbdelrahmanHafez modified the milestones: 5.11.6, 5.11.5 Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

2 participants