Skip to main content
Version: 1.2.6

Mathematical Operations

Algebric functions like Sum,Min,Max etc are implemented here.
This page uses the following methods: function: sum(), min(), max(),

  • await presql.math(<filter>)
  • await presql.table('').math(<filter>).{function} -Comming Soon
index.js
import presql from "./connection";

async function MathFunctions() {
const data = await presql.math({
table: "cart",
set: {
column: "productPrice", // column name in cammelCase
type: "", // sum,min,avg,max,count,
},
select: {
firstName: true, // use this syntax
},
where: { email: "[email protected]" },
sortBy: {
id: true, // use this syntax
asc: true,
},
});
console.log(data); // if showResults is true, it will print results
}
Remember

set is required parameter ,select,where,sortBy are optional, use them to filter

Write coloumn name: if table column join by some special characters please use cammelCase instead writing same as it is name Original Table Column Name : product_price

Correct Syntax : productPrice InCorrect Syntax : product_price. Define type property to use Math Functions.

set: {
column: "productPrice", // column name in cammelCase
type: "", // sum,min,avg,max,count,
}, ```