70 lines
1.3 KiB
JavaScript
70 lines
1.3 KiB
JavaScript
const config = require('../../config');
|
|
const providers = config.providers;
|
|
const crypto = require('crypto');
|
|
const bcrypt = require('bcrypt');
|
|
const moment = require('moment');
|
|
|
|
module.exports = function (sequelize, DataTypes) {
|
|
const facilities = sequelize.define(
|
|
'facilities',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
facility_name: {
|
|
type: DataTypes.TEXT,
|
|
},
|
|
|
|
facility_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
values: [
|
|
'CommunityGarden',
|
|
|
|
'Festival',
|
|
|
|
'Park',
|
|
|
|
'Maintenance',
|
|
|
|
'GarbagePickup',
|
|
],
|
|
},
|
|
|
|
event_date: {
|
|
type: DataTypes.DATE,
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
facilities.associate = (db) => {
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
//end loop
|
|
|
|
db.facilities.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.facilities.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
return facilities;
|
|
};
|