|
|
|
const mongoose = require('mongoose')
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
const ObjectId = Schema.Types.ObjectId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const installationschema = new mongoose.Schema({
|
|
|
|
// name: { type: String },
|
|
|
|
phone: { type: String, unique: true, trim: true },
|
|
|
|
address: String,
|
|
|
|
installationId: { type: String },
|
|
|
|
phoneVerified: { type: Boolean, default: false },
|
|
|
|
phoneVerificationCode: { type: Number, default: 11111 },
|
|
|
|
passwordResetCode: { type: Number},
|
|
|
|
oneTimePasswordSetFlag: { type: Boolean, default: false },
|
|
|
|
emails: [{ email: String, verified: { type: Boolean, default: false } }],
|
|
|
|
services: { password: { bcrypt: String } },
|
|
|
|
alternativeNumber: { type: String, default: null },
|
|
|
|
firstName: { type: String, default: null },
|
|
|
|
lastName: { type: String, default: null },
|
|
|
|
address1: { type: String, default: null },
|
|
|
|
address2: { type: String, default: null },
|
|
|
|
city: { type: String, default: null },
|
|
|
|
profile: {
|
|
|
|
|
|
|
|
state: { type: String, default: null },
|
|
|
|
country: { type: String, default: null },
|
|
|
|
},
|
|
|
|
team : { type: String, default: null},
|
|
|
|
manager : { type: String, default: null},
|
|
|
|
|
|
|
|
longitude: { type : Number,default: 0.0},
|
|
|
|
latitude: {type: Number,default: 0.0},
|
|
|
|
|
|
|
|
fcmId: { type: String, default: null },
|
|
|
|
createdAt: {
|
|
|
|
type: Date,
|
|
|
|
default: function () {
|
|
|
|
return Date.now();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
createdBy: ObjectId,
|
|
|
|
updatedAt: {
|
|
|
|
type: Date,
|
|
|
|
default: function () {
|
|
|
|
return Date.now();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
updatedBy: ObjectId,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const profilePictureInstallSchema = new Schema({
|
|
|
|
installationId: {
|
|
|
|
type: String,
|
|
|
|
unique: true,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
picture: {
|
|
|
|
type: String, // Change the type to String
|
|
|
|
required: true,
|
|
|
|
validate: {
|
|
|
|
validator: function (value) {
|
|
|
|
const supportedFormats = ['jpg', 'jpeg', 'png'];
|
|
|
|
const fileExtension = value.split('.').pop().toLowerCase();
|
|
|
|
return supportedFormats.includes(fileExtension);
|
|
|
|
},
|
|
|
|
message: 'Picture must be a JPEG, PNG, or JPG image'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const ProfilePictureInstall = mongoose.model('ProfilePictureInstall', profilePictureInstallSchema);
|
|
|
|
|
|
|
|
const Install = mongoose.model("Install", installationschema);
|
|
|
|
|
|
|
|
module.exports = { Install, ProfilePictureInstall};
|