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
Final checks
Describe the feature
Currently, only uid size is configurable in
Uidattribute, 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
@Uiddecorator. 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?: numberwithoptions?: Record<string, any>where possible, pass this parameter down to custom uid casts, and allow its usage in decorators.Example usage:
This will generate secure nanoids with the length of 7 chars using custom alphabet.
Additional information
Final checks