You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default data is represented as collections of items. But in some cases it makes sense to have a more specific query or mutation other than the CRUD-style of the querying API. Examples: currentUser, logout()...
Suggested solution
(Subject to change)
const model = {
name: 'User',
global: {
currentUser: {
query: true, // Allow querying
state: { // State stored in the cache
currentUserId: null
},
find: (state) => ({ // Find options (same as in query API)
// filter: user => user.id === state.currentUserId,
key: state.currentUserId,
}),
},
logout: {
mutation: true, // Allow mutation-style calling
},
// or
logout () {
await $fetch('/api/logout')
this.store.User.state.currentUserId = null
},
},
}
Clear and concise description of the problem
By default data is represented as collections of items. But in some cases it makes sense to have a more specific query or mutation other than the CRUD-style of the querying API. Examples:
currentUser
,logout()
...Suggested solution
(Subject to change)
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: