Create slug based on title field.
I currently have a product schema that has title field that is a nonNull text. I want to create a slug that is automatically generated. My current approach to this is using the
.$defaultFn((title) => createSlug(title))
but I am struggling to find a way to reference title in the defaultFn. Is there some way to do this?3 Replies
I am having this exact issue as well. Scoured the project; $default and $onUpdate don't pass any parameters
the quick hack i've found is you can create a slug when you are inserting an object to the database (create slug client side and then add it to the db)
but this is not an ideal solution
yeah, it's a derived value, so it shouldn't be in the client logic (ideally), in the same way that there's tools to manage createdAt/updatedAt