You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
In short: I'm reusing a single schema for both a collection and as a subdocument. Indexes behave funny when I do so, because the collection's indexes are also used for the other collection where the collection's entries are subdocuments. I want to get rid of the indexes in the latter. This problem is a result of my database denormalisation.
There is a very helpful suggestion in that thread (the 1st one), which includes cloning the schema and setting off autoIndex on the copy. This is relatively elegant. So question numero uno -- is this possible in typegoose, somehow? Typegoose schemas are classes. I don't think I can copy them.
If the first question doesn't work out, I'd like to ask how to approach this differently? I can think of the following. Make on index-less class Event. Use that for subdocuments. Then extend this class with an class IndexedEvent extends Event that does have all the @index operators. Use this for the database collection. I think this would work. Just should refer to both by the super-class Event for interoperability. So never have a DocumentType<IndexedEvent>.
What do you think, @hasezoey? And again, much obliged for putting up with my questions.
The text was updated successfully, but these errors were encountered:
Please see Automattic/mongoose#9128.
In short: I'm reusing a single schema for both a collection and as a subdocument. Indexes behave funny when I do so, because the collection's indexes are also used for the other collection where the collection's entries are subdocuments. I want to get rid of the indexes in the latter. This problem is a result of my database denormalisation.
There is a very helpful suggestion in that thread (the 1st one), which includes cloning the schema and setting off
autoIndex
on the copy. This is relatively elegant. So question numero uno -- is this possible in typegoose, somehow? Typegoose schemas are classes. I don't think I can copy them.If the first question doesn't work out, I'd like to ask how to approach this differently? I can think of the following. Make on index-less class Event. Use that for subdocuments. Then extend this class with an
class IndexedEvent extends Event
that does have all the@index
operators. Use this for the database collection. I think this would work. Just should refer to both by the super-classEvent
for interoperability. So never have aDocumentType<IndexedEvent>
.What do you think, @hasezoey? And again, much obliged for putting up with my questions.
The text was updated successfully, but these errors were encountered: