feat: complete tasks 1 to 15

This commit is contained in:
Ayobami
2025-07-25 22:16:08 +01:00
parent a5dbf762b6
commit fe95626d9f
15 changed files with 3723 additions and 37 deletions
+30
View File
@@ -0,0 +1,30 @@
module.exports = (sequelize, DataTypes) => {
const analytic = sequelize.define(
"analytic",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
create_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
},
widget_name: {
type: DataTypes.STRING,
allowNull: false,
},
browser_type: {
type: DataTypes.STRING,
allowNull: false,
},
},
{
timestamps: false,
freezeTableName: true,
tableName: "analytic",
}
);
return analytic;
};
+83
View File
@@ -0,0 +1,83 @@
"use strict";
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2020*/
/**
* Sequelize File
* @copyright 2020 Manaknightdigital Inc.
* @link https://manaknightdigital.com
* @license Proprietary Software licensing
* @author Ryan Wong
*
*/
const fs = require("fs");
const path = require("path");
let Sequelize = require("sequelize");
const basename = path.basename(__filename);
const { DataTypes } = require("sequelize");
const config = {
DB_DATABASE: "mysql",
DB_USERNAME: "root",
DB_PASSWORD: process.env.DB_PASSWORD || "root",
DB_ADAPTER: "mysql",
DB_NAME: "day_17",
DB_HOSTNAME: "localhost",
DB_PORT: 3306,
};
let db = {};
let sequelize = new Sequelize(
config.DB_NAME,
config.DB_USERNAME,
config.DB_PASSWORD,
{
dialect: config.DB_ADAPTER,
username: config.DB_USERNAME,
password: config.DB_PASSWORD,
database: config.DB_NAME,
host: config.DB_HOSTNAME,
port: config.DB_PORT,
logging: console.log,
timezone: "-04:00",
pool: {
maxConnections: 1,
minConnections: 0,
maxIdleTime: 100,
},
define: {
timestamps: false,
underscoredAll: true,
underscored: true,
},
}
);
sequelize
.sync()
.then(() => {
console.log("Database & tables created!");
})
.catch((err) => {
console.log(err);
});
fs.readdirSync(__dirname)
.filter((file) => {
return (
file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js"
);
})
.forEach((file) => {
var model = require(path.join(__dirname, file))(sequelize, DataTypes);
db[model.name] = model;
});
Object.keys(db).forEach((modelName) => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
+26
View File
@@ -0,0 +1,26 @@
module.exports = (sequelize, DataTypes) => {
const location = sequelize.define(
"location",
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: DataTypes.STRING,
created_at: DataTypes.DATEONLY,
updated_at: DataTypes.DATE,
},
{
timestamps: true,
freezeTableName: true,
tableName: "location",
},
{
underscoredAll: false,
underscored: false,
}
);
return location;
};