ORM models added
This commit is contained in:
45
Database/model/adminUserModel.js
Normal file
45
Database/model/adminUserModel.js
Normal file
@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require("../mySQL.js")
|
||||
|
||||
const adminUserModel = sequelize.define('adminusers', {
|
||||
// Model attributes are defined here
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
username: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 50
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
lastLogin: {
|
||||
type: DataTypes.timestamps,
|
||||
allowNull: true,
|
||||
},
|
||||
jobTitle: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
}
|
||||
},{
|
||||
timestamps: false, // Disable automatic timestamps
|
||||
});
|
||||
|
||||
module.exports = { adminUserModel }
|
40
Database/model/userMode.js
Normal file
40
Database/model/userMode.js
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require("../mySQL.js")
|
||||
|
||||
const userModel = sequelize.define('users', {
|
||||
// Model attributes are defined here
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
username: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 50
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
lastLogin: {
|
||||
type: DataTypes.timestamps,
|
||||
allowNull: true,
|
||||
}
|
||||
},{
|
||||
timestamps: false, // Disable automatic timestamps
|
||||
});
|
||||
|
||||
module.exports = { userModel }
|
@ -1,16 +1,16 @@
|
||||
require("dotenv").config({ path: "../../.env" });
|
||||
require("dotenv").config({ path: "../.env" });
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
const sequelize = new Sequelize(
|
||||
"your_database_name",
|
||||
process.env.
|
||||
process.env.,
|
||||
{
|
||||
host: '',
|
||||
dialect: 'mysql'
|
||||
}
|
||||
);
|
||||
"adminusers",
|
||||
process.env.DB_USER,
|
||||
process.env.DB_PASS,
|
||||
|
||||
{
|
||||
host: "mpsqldatabasean.mysql.database.azure.com",
|
||||
dialect: 'mysql'
|
||||
}
|
||||
);
|
||||
|
||||
sequelize.authenticate().then(() => {
|
||||
console.log('Connection has been established successfully.');
|
||||
|
Reference in New Issue
Block a user