-
Notifications
You must be signed in to change notification settings - Fork 22
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
Slug is always undefined / null #37
Comments
I would advice you setup options, the defaults are causing this error. The plugin is probably adding an index and the values are not unique which is also set as a default. |
I do want unique slugs in fact, as far as I understood it would add an incrementing number in case the slug already exists in the schema. As I said I assume it's shown the unique issue because it's trying to use "undefined" for each slug (that only works once since it's supposed to be unique). Seems to be a bug if you ask me. Maybe it is because I do upserts for saving new documents? |
Please submit a reproduction, the test for this passes. |
Same issue obtained. Getting slug value as undefined for inserting documnet using upsert option. |
I was having the same issue, but I think I found out how to solve it. In a first version, I set the plugin like Deleting the first index did the job for me, no more errors! MAYBE the plugin could try to verify if there is a unique "slug" index on the collection that it's not using and delete it automatically, but I'm not really sure how feasible this is. It would have to create indices with a predefined suffix or prefix so it could do that. Not sure if it's worth it. But I think this can be a common issue during the development phase, so documenting this is a good idea, I guess 😛 |
@talha-asad I'm thinking about writing a little Heads Up section on the project's Readme about this specific case, what do you think? |
Sounds like a good idea. |
It's the first time I am trying this library, might be pretty useful in many of my projects, however I can't figure out why it's not working at all at the moment.
That's how I define my model in TypeScript:
And this is the relevant snippet which is executed for upserting the documents:
The issue:
It inserts exactly one document into my collection, so I assume this issue pops up because it can't insert a second document with null as key for my slug field. Why is it not sluggifying and inserting my field when I upsert documents?
The text was updated successfully, but these errors were encountered: