# Accounts and/or Contacts Store
Store that has the information regarding accounts and contacts of the instance. They have the performance improvements such as pagination and lazy loading implemented out of the box, also supports normalized searching and customAccountFilters
/customContactFilters
out of the box.
# createAccountsStore()
Before using the accountStore
, you would need to initialize it to prepare the store and initialize it with data. This can be done in any parent components of the accountsStore
consumer, or in the same component.
import { createAccountsStore } from '@pitcher/core'
export default {
name: 'app',
setup() {
createAccountsStore({
selectColumns: [ // columns to select from the table
'Accounts.id as id',
'Accounts.accountName as name',
'Accounts.account as account'
],
searchFields: ['account.Name', 'account.Type', 'account.City'], // fields that will be included in the normalized search query
defaultSortBy: 'account.Name', // field to sort by
defaultItemsPerPage: 10, // item count for pagination
})
}
}
# useAccounts()
After initializing the store with using the createAccountsStore
, you can access the account data with this store.
import { useAccounts } from '@pitcher/core'
export default {
name: 'app',
setup() {
const {
data, // ref holding the current page of accounts
loading, // indicator if new data is being fetched
searchString, // string to be used for normalized query
selectedFilters, // selected values of customAccountFilters
pageLength, // current length of the page
rowCount, // total amount of data for the current filtering criteria
fetchOptions, // same signature with the VDataTable fetchOptions prop
fetchAllMatchingFilter, // function to fetch all data that matches current filtering, usefull if the whole data is needed rather than paginated data, but be carefull since this might cause performance problems
} = useAccounts()
}
# createContactsStore()
Before using the contactStore
, you would need to initialize it to prepare the store and initialize it with data. This can be done in any parent components of the contactStore
consumer, or in the same component.
import { createContactsStore } from '@pitcher/core'
export default {
name: 'app',
setup() {
createContactsStore({
accountId: null | '' // if you'd like to use contacts of a specific account id of that account should be provided
selectColumns: [ // columns to select from the table
'DISTINCT(Contacts.contact) as contact', 'Accounts.account'
],
searchFields: ['contact.Name', 'contact.Title', 'account.Name', 'account.Type', 'account.City'], // fields that will be included in the normalized search query
defaultSortBy: 'contact.Name', // field to sort by
defaultItemsPerPage: 10, // item count for pagination
})
}
}
# useContacts()
After initializing the store with using the createContactsStore
, you can access the contact data with this store.
import { useContacts } from '@pitcher/core'
export default {
name: 'app',
setup() {
const {
data, // ref holding the current page of contacts
loading, // indicator if new data is being fetched
searchString, // string to be used for normalized query
selectedFilters, // selected values of customContactFilters
pageLength, // current length of the page
rowCount, // total amount of data for the current filtering criteria
fetchOptions, // same signature with the VDataTable fetchOptions prop
fetchAllMatchingFilter, // function to fetch all data that matches current filtering, usefull if the whole data is needed rather than paginated data, but be carefull since this might cause performance problems
} = useContacts()
}