@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.
22 lines (18 loc) • 681 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));
if (typeof value !== "string") throw new TypeError(errors.baseNotString);
await this.set(
table,
key,
Buffer.from(value, "binary").toString("base64"),
true
);
return this.base_get(table, key);
};