code example for CSV Importer with Node

Co-authored-by: Arpendu Kumar Garai <Arpendu.KumarGarai@microfocus.com>
This commit is contained in:
Arpendu Kumar Garai
2022-12-05 04:20:13 +05:30
committed by GitHub
parent 3930e1cb03
commit cd69fa5842
27 changed files with 915 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
import Sequelize from 'sequelize';
import { sequelize } from '../database/index.js';
const Employee = sequelize.define("employee", {
id: {
type: Sequelize.STRING,
primaryKey: true
},
name: {
type: Sequelize.STRING
},
email: {
type: Sequelize.STRING
},
username: {
type: Sequelize.STRING
},
dob: {
type: Sequelize.STRING
},
company: {
type: Sequelize.STRING
},
address: {
type: Sequelize.STRING
},
location: {
type: Sequelize.STRING
},
salary: {
type: Sequelize.STRING
},
about: {
type: Sequelize.STRING
},
role: {
type: Sequelize.STRING
},
managedBy: {
type: Sequelize.STRING,
references: {
model: 'employees',
key: 'id'
}
},
createdAt: {
type: Sequelize.STRING
},
updatedAt: {
type: Sequelize.STRING
},
avatar: {
type: Sequelize.STRING
}
});
Employee.hasMany(Employee, {
as: 'children',
foreignKey: 'managedBy',
sourceKey: 'id',
useJunctionTable: false
});
Employee.belongsTo(Employee, {
foreignKey: "managedBy",
targetKey: "id",
});
export default Employee;