/
home
/
infinitibizsol
/
.trash
/
model.3
/
contact
/
File Upload :
llllll
Current File: /home/infinitibizsol/.trash/model.3/contact/contact.js
import db from "../../model/index"; import mongoose from "mongoose"; const Contact = new mongoose.Schema( { contact_type: { type: String, required: true, }, customer_type: { type: String, required: true, }, current_status: { type: String, required: true, }, first_name: { type: String, required: true }, last_name: { type: String, required: true }, location: { type: String, required: false }, email: { type: String, required: true }, profile_picture: { type: String, required: false }, created_by: { type: mongoose.Schema.ObjectId, ref: "User", required: true, }, deleted: { type: Boolean, default: false, }, createdOn: { type: Date, default: Date.now }, modifiedOn: { type: Date, default: Date.now }, }, { toJSON: { virtuals: true }, toObject: { virtuals: true }, } ); Contact.index({ first_name: "text", last_name: "text", email: "text", location: "text", }); Contact.pre("remove", async function (next) { try { await db.Address.deleteMany({ contact_id: this._id }); await db.BasicContactInfo.deleteMany({ contact_id: this._id }); await db.File.deleteMany({ contact_id: this._id }); await db.Note.deleteMany({ contact_id: this._id }); await db.PersonalInfo.deleteMany({ contact_id: this._id }); await db.SocialMedia.deleteMany({ contact_id: this._id }); await db.Task.deleteMany({ contact_id: this._id }); await db.Employee.deleteMany({ contact_id: this._id }); await db.ExpireDate.deleteMany({ contact_id: this._id }); await db.LinkedAccount.deleteMany({ contact_id: this._id }); await db.Policy.deleteMany({ contact_id: this._id }); await db.AccountInfo.deleteMany({ contact_id: this._id }); await db.AdditionalContact.deleteMany({ contact_id: this._id }); next(); } catch (err) { next(err); } }); export default mongoose.model("Contact", Contact);
Copyright ©2k19 -
Hexid
|
Tex7ure