@onurege3467/zerohelper
Version:
ZeroHelper is a versatile JavaScript library offering helper functions and database utilities for developers. It supports MongoDB, MySQL, SQLite, Redis, and PostgreSQL.
18 lines (14 loc) • 633 B
JavaScript
;
const errors = require("../errors/strings.js");
module.exports = async function (key, value, table = "default") {
if (!table || typeof table !== "string")
throw new TypeError(errors.table.replace("{received}", typeof table));
if (!key || typeof key !== "string")
throw new TypeError(errors.key.replace("{received}", typeof key));
if (value === undefined)
throw new TypeError(errors.value.replace("{received}", typeof value));
let data = (await this.get(table, key)) || [];
if (!Array.isArray(data))
throw new TypeError(errors.array.replace("{key}", key));
return data.includes(value);
};