This wrapper gives a collection a lot of helper functions
For Details what each function can do, look at the separate composable for it e.g. min
-> useMin
import { useRepo } from 'pinia-orm'import { useCollect } from 'pinia-orm/dist/helpers'import User from './models/User'const users = useRepo(User).all()// order a collection by 'name' attributesuseCollect(users).orderBy('name')// get the min of the 'age' attributeuseCollect(users).min('age')// get the max of the 'age' attributeuseCollect(users).max('age')// get the sum of the 'age' attributeuseCollect(users).sum('age')// sort by 'age' attributeuseCollect(users).sortBy('age')// get all values in 'age' attributeuseCollect(users).pluck('age')// get all primary keysuseCollect(users).keys()
export interface UseCollect<M extends Model = Model> { sum: (field: string) => number min: (field: string) => number max: (field: string) => number pluck: (field: string) => any[] groupBy: (fields: string[] | string) => Record<string, Collection<M>> sortBy: (sort: sorting<M>) => M[] keys: () => string[]}export function useCollect<M extends Model = Model>(models: Collection<M>): UseCollect<M>