Skip to main content
Version: 1.2.4

Exist

Check the data exists or not in the database table.
This function returns boolean or result, depending on what user specified

  • await isExist(<filter>)
  • await presql.isExist('') -Comming Soon
Don't Forget

This Function requires two arguments await presql.exist({},boolean)

  • First argument is an object which contains {table:"tableName",where:{}}, where is filter condition ,based on that it returns. select is an optional field, if the second argument is (boolean) is set to be false then it return result otherwise if set to be true, and select is passed throw an error.
  • Second argument is an boolean value true or false, default it is false

If boolean value is set to true then it returns result object[], set to false returns a boolean value , true means data exists , false means data not exists.

index.js
import presql from "./connection";

async function isUserExist() {
const data = presql.exist({
{
table: "extensions",//required
where: {
id: 4,
},
select: {
act: true,
name: true,
},// select is optional, if true is pass then select will not work ,throw an error , to use select fields, pass second value false
},
true // this will fetch result return object[] if it is true, default is false only return boolean value , that value exist or not
});

console.log(data); // if showResults is true, it will print results
}