Support compound index in @Schema decorator
Closed this issue · 1 comments
GiovanniCardamone commented
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 commented
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.