34 lines
784 B
JavaScript
34 lines
784 B
JavaScript
/**
|
|
* Model for managing sites table in the database.
|
|
*/
|
|
|
|
const { supabase } = require('../auth');
|
|
|
|
class SiteModel {
|
|
|
|
static tableName = 'sites';
|
|
|
|
/**
|
|
* Inserts a new site into the database.
|
|
*
|
|
* @param {string} name - The name of the site.
|
|
* @param {string} domainName - The domain name of the site.
|
|
*
|
|
* @returns {Promise<Object>} - The result of the insert operation.
|
|
*/
|
|
async insertSite(name, domainName) {
|
|
const { error } = await supabase.from(siteModel.tableName).insert({
|
|
name: name,
|
|
domain_name: domainName,
|
|
});
|
|
|
|
if (error) {
|
|
console.error('Error inserting site:', error);
|
|
throw error;
|
|
}
|
|
|
|
return data;
|
|
}
|
|
}
|
|
|
|
module.exports = SiteModel; |