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

Support compound index in @Schema decorator #1836

Closed
1 task done
GiovanniCardamone opened this issue Jun 24, 2023 · 1 comment
Closed
1 task done

Support compound index in @Schema decorator #1836

GiovanniCardamone opened this issue Jun 24, 2023 · 1 comment
Labels

Comments

@GiovanniCardamone
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Mongo support compound index compound index

and would be nice to declare the compound index directly in the schema decorator

Mongoose already support the compound index creation

Describe the solution you'd like

here is an example

@Schema({
  compounds: [
    [{ name: 1, surname: 1 }, { unique: true }]
  ]
})
class MyCollection {
  @Prop()
  name: string
  
  @Prop()
  surname: string
}

Teachability, documentation, adoption, migration strategy

Documentations:

https://mongoosejs.com/docs/api/schema.html#Schema.prototype.index()

https://www.mongodb.com/docs/manual/core/index-compound/

What is the motivation / use case for changing the behavior?

because make it more readable and i think compund index should be part of Schema definition

@kamilmysliwiec
Copy link
Member

You should use YOUR_SCHEMA.index() method for this.

There are no plans to implement it in the foreseeable future.

If you think your request could live outside Nest's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

@nestjs nestjs locked and limited conversation to collaborators Jun 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants