-
-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the feature
Currently, only uid size is configurable in Uid attribute, and it's only passed to default implementation (generateId) and not the custom uid casts. For example, you cannot use supplied secure nanoid cast with custom size, or you cannot provide custom alphabet.
Also, there's no way to pass uid size to @Uid decorator. So, @Uid(7) won't generate uid with a size of 7 chars, but create default 21-char uid.
My suggestion is to replace size?: number with options?: Record<string, any> where possible, pass this parameter down to custom uid casts, and allow its usage in decorators.
Example usage:
import { Model } from 'pinia-orm'
import { Uid } from 'pinia-orm/nanoid'
class User extends Model {
static entity = 'users'
@Uid({ size: 7, alphabet: '0123456789abcdef' })
declare id: string
}This will generate secure nanoids with the length of 7 chars using custom alphabet.
Additional information
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Check existing discussions and issues.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request