useSum()

Usage

import { useRepo } from 'pinia-orm'
import { useSum } from 'pinia-orm/helpers'
import User from './models/User'
const users = useRepo(User).all()
// get the sum of the 'age' attribute
useSum(users, 'age')
// get the sum of the 'role.title' attribute. The dot notation works only for 1n1 Relations
useSum(users, 'role.title')

Type Declaration

export function useSum(models: Collection, field: string): number
Table of Contents