puddysql
Version:
🍮 Powerful SQL toolkit for Node.js, built with flexibility and structure in mind. Easily manage SQLite3/PostgreSQL, advanced queries, smart tag systems, and full JSON-friendly filters.
56 lines (50 loc) • 1.43 kB
JavaScript
;
/**
* List of event names used by PuddySql in the EventEmitter.
* Each key maps to its string identifier.
*/
class PuddySqlEvents {
/**
* This class is not meant to be instantiated.
*
* PuddySqlEvents is a static-only class. All its members should be accessed directly through the class.
*
* @throws {Error} Always throws an error saying you can't summon it like a tiny pudding.
*/
constructor() {
throw new Error(
"Oops! PuddySqlEvents isn't something you can summon like a tiny pudding. Just use it statically 🍮 :3",
);
}
/**
* Constant identifier used to represent a connection failure.
*
* This can be thrown, logged, or compared when the database connection is not available.
*
* @type {string}
* @static
*/
static ConnectionError = 'Connection-Error';
/**
* @returns {string[]}
*/
static get all() {
const items = [];
for (const key of Object.getOwnPropertyNames(this)) {
// Skip getters or non-string static properties
if (key !== 'name') {
const descriptor = Object.getOwnPropertyDescriptor(this, key);
if (descriptor && typeof descriptor.value === 'string') items.push(descriptor.value);
}
}
return items;
}
/**
* @param {string} event
* @returns {boolean}
*/
static isValid(event) {
return this.all.includes(event);
}
}
module.exports = PuddySqlEvents;