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

Schema#index() does't support alias #13276

Closed
2 tasks done
teadrinker2015 opened this issue Apr 14, 2023 · 1 comment
Closed
2 tasks done

Schema#index() does't support alias #13276

teadrinker2015 opened this issue Apr 14, 2023 · 1 comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone

Comments

@teadrinker2015
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

7.0.3

Node.js version

18.13.0

MongoDB server version

6

Typescript version (if applicable)

No response

Description

as below

Steps to Reproduce

const s = new mongoose.Schema({
    _id: { type: String, alias: 'foo' }
})

s.index({ foo: 1 }) // this doesn't work on '_id'

This is just for simplification. I know it doesn't make sense to index (b-tree) on _id which has already been done automatically. I actually use a lot of nested compound unique indexes. That's why I desperately need alias.

Expected Behavior

No response

@teadrinker2015
Copy link
Author

teadrinker2015 commented Apr 14, 2023

Sorry, I realized alias is just a convenient virtual kind of getter, setter for Document instances. Closing this issue.

@vkarpov15 vkarpov15 reopened this Apr 19, 2023
@vkarpov15 vkarpov15 added the enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature label Apr 19, 2023
@vkarpov15 vkarpov15 added this to the Parking Lot milestone Apr 19, 2023
@vkarpov15 vkarpov15 modified the milestones: Parking Lot, 7.5 Jul 26, 2023
vkarpov15 added a commit that referenced this issue Jul 26, 2023
enhancement: can index using the alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Projects
None yet
Development

No branches or pull requests

2 participants