The base key is the root identifier for all keys generated by the factory. It's the first element in every generated key array.
Example
typescript
const keys = createKeyFactory('myApp', {
// ... your schema
});
// All keys will start with 'myApp'
keys.users.all({}) // => ['myApp', 'users', 'all']
keys.posts.detail({ id: '123' }) // => ['myApp', 'posts', 'detail', '123']Choosing a Base Key
Choose a base key that:
- Identifies your application: Use your app name or a unique identifier
- Is consistent: Use the same base key throughout your application
- Is descriptive: Make it clear what the keys belong to
Common Patterns
typescript
// Application name
const keys = createKeyFactory('myApp', { ... });
// API identifier
const keys = createKeyFactory('api', { ... });
// Feature identifier
const keys = createKeyFactory('dashboard', { ... });