- 1 :
/**
- 2 :
* Providers are special pieces that give you easy access to various data storage systems
- 3 :
* using a consistent and predictable set of methods
- 4 :
* @module Provider
- 5 :
* @example <caption> The following structure is needed for SettingGateway compatibility. </caption>
- 6 :
* exports.hasTable = (table) => { // code here };
- 7 :
* exports.createTable = (table) => { // code here };
- 8 :
* exports.getAll = (table) => { // code here };
- 9 :
* exports.get = (table, id) => { // code here };
- 10 :
* exports.create = (table, id, document) => { // code here };
- 11 :
* exports.delete = (table, id) => { // code here };
- 12 :
* exports.update = (table, id, document) => { // code here };
- 13 :
* exports.replace = (table, id, document) => { // code here };
- 14 :
* exports.conf = {};
- 15 :
*/
- 16 :
- 17 :
/**
- 18 :
* Checks if a table exists.
- 19 :
* @param {string} table The name of the table you want to check.
- 20 :
* @return {Promise<boolean>}
- 21 :
*/
- 22 :
exports.hasTable = (table) => ({}); // eslint-disable-line
- 23 :
- 24 :
/**
- 25 :
* Create a new table.
- 26 :
* @param {string} table The name for the new table.
- 27 :
* @return {Promise<*>}
- 28 :
*/
- 29 :
exports.createTable = (table) => ({}); // eslint-disable-line
- 30 :
- 31 :
/**
- 32 :
* Get all entries from a table.
- 33 :
* @param {string} table The name of the table to fetch from.
- 34 :
* @return {Promise<Array<{}>>}
- 35 :
*/
- 36 :
exports.getAll = (table) => ({}); // eslint-disable-line
- 37 :
- 38 :
/**
- 39 :
* Get an entry from a table.
- 40 :
* @param {string} table The name of the table to fetch from.
- 41 :
* @param {string} id The ID of the entry to get.
- 42 :
* @return {Promise<Array<{}>>}
- 43 :
*/
- 44 :
exports.get = (table, id) => ({}); // eslint-disable-line
- 45 :
- 46 :
/**
- 47 :
* Create a new entry into a table.
- 48 :
* @param {string} table The name of the table to update.
- 49 :
* @param {string} id The ID for the new entry.
- 50 :
* @param {Object} document A JSON object.
- 51 :
* @return {Promise<*>}
- 52 :
*/
- 53 :
exports.create = (table, id, document) => ({}); // eslint-disable-line
- 54 :
- 55 :
/**
- 56 :
* Delete an entry from a table.
- 57 :
* @param {string} table The name of the table to update.
- 58 :
* @param {string} id The ID of the entry to delete.
- 59 :
* @return {Promise<Array<{}>>}
- 60 :
*/
- 61 :
exports.delete = (table, id) => ({}); // eslint-disable-line
- 62 :
- 63 :
/**
- 64 :
* Update an entry from a table.
- 65 :
* @param {string} table The name of the table to update.
- 66 :
* @param {string} id The ID of the entry to update.
- 67 :
* @param {Object} document A JSON object.
- 68 :
* @return {Promise<*>}
- 69 :
*/
- 70 :
exports.update = (table, id, document) => ({}); // eslint-disable-line
- 71 :
- 72 :
/**
- 73 :
* Replace an entry from a table.
- 74 :
* @param {string} table The name of the table to update.
- 75 :
* @param {string} id The ID of the entry to update.
- 76 :
* @param {Object} document The new JSON object for the document.
- 77 :
* @return {Promise<*>}
- 78 :
*/
- 79 :
exports.replace = (table, id, document) => ({}); // eslint-disable-line
- 80 :
- 81 :
/**
- 82 :
* An object that configures the provider.
- 83 :
* @type {Conf}
- 84 :
* @example
- 85 :
* exports.conf = {
- 86 :
* enabled: true,
- 87 :
* moduleName: "json",
- 88 :
* priority: 0
- 89 :
* };
- 90 :
*/
- 91 :
exports.conf = {};
- 92 :
- 93 :
/**
- 94 :
* Some providers are SQL, and due to the No-SQL environment that exists in SettingGateway,
- 95 :
* they require extra methods/properties to work. All the previous methods are required to work.
- 96 :
* @module ProviderSQL
- 97 :
* @example <caption> SQL Compatibility </caption>
- 98 :
* exports.updateColumns = (table, columns, schema) => { // code here };
- 99 :
* exports.serialize = (data) => { // code here };
- 100 :
* exports.sanitize = (string) => { // code here };
- 101 :
* exports.CONSTANTS = {};
- 102 :
*/
- 103 :
- 104 :
/**
- 105 :
* Update the columns from a table (All the data is provided by the SQL class).
- 106 :
* @param {string} table The name of the table.
- 107 :
* @param {string[]} columns Array of columns.
- 108 :
* @param {array[]} schema Tuples of keys/values from the schema.
- 109 :
* @returns {boolean}
- 110 :
*/
- 111 :
exports.updateColumns = (table, columns, schema) => ({}); // eslint-disable-line
- 112 :
- 113 :
/**
- 114 :
* Transform NoSQL queries into SQL.
- 115 :
* @param {Object} data The object.
- 116 :
* @returns {Object}
- 117 :
*/
- 118 :
exports.serialize = (data) => ({}); // eslint-disable-line
- 119 :
- 120 :
/**
- 121 :
* Sanitize strings to be storable into the SQL database.
- 122 :
* @param {*} string An object or string.
- 123 :
* @returns {string}
- 124 :
*/
- 125 :
exports.sanitize = (string) => ({}); // eslint-disable-line
- 126 :
- 127 :
/**
- 128 :
* An object that helps the SQL class creating compatible schemas for the provider.
- 129 :
* @property {string} String The SQL compatible string datatype.
- 130 :
* @property {string} Integer The SQL compatible integer datatype.
- 131 :
* @property {string} Float The SQL compatible float datatype.
- 132 :
* @example
- 133 :
* exports.CONSTANTS = {
- 134 :
* String: "TEXT",
- 135 :
* Integer: "INTEGER",
- 136 :
* Float: "INTEGER",
- 137 :
* AutoID: "INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE",
- 138 :
* Timestamp: "DATETIME",
- 139 :
* AutoTS: "DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL",
- 140 :
* };
- 141 :
*/
- 142 :
exports.CONSTANTS = {};