First of all, thanks so much for this awesome plugin! We're using it on a project that implements discriminators and ran into a problem where specifying the slug as unique:true threw errors. For example, if you had a base schema named Car, and had two discriminator schemas named Volvo and Toyota. If I wanted to create a "model" of "Road Rager" for both Volvo and Toyota, but make sure the slug was "road-rager" for both (and not "road-rager-1" for the second instance), this would be impossible with simply adding unique:true to the slug field because Mongoose throws an error if two discriminator models share the same slug.
Thankfully (!), you already had a property in your source code that would allow for a unique slug, but not use Mongoose's own unique method. I'm simply asking that you document this feature since it would be extremely helpful for folks using discriminators, but still want the unique slug feature. Thanks again!
slug: {
type: String,
slug: "name",
slug_padding_size: 1,
unique_slug: true, // <-- works like a charm with discriminators :)
// unique: true <-------- this throws an error if two discriminator models want the same slug!
}
First of all, thanks so much for this awesome plugin! We're using it on a project that implements discriminators and ran into a problem where specifying the slug as
unique:true
threw errors. For example, if you had a base schema namedCar
, and had two discriminator schemas namedVolvo
andToyota
. If I wanted to create a "model" of "Road Rager" for both Volvo and Toyota, but make sure the slug was "road-rager" for both (and not "road-rager-1" for the second instance), this would be impossible with simply addingunique:true
to the slug field because Mongoose throws an error if two discriminator models share the same slug.Thankfully (!), you already had a property in your source code that would allow for a unique slug, but not use Mongoose's own unique method. I'm simply asking that you document this feature since it would be extremely helpful for folks using discriminators, but still want the unique slug feature. Thanks again!