Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mongoose = require('mongoose');
- const Schema = mongoose.Schema;
- const nationalities = require('../constants/nationalities')
- const genders = require('../constants/gender')
- const hair_color = require('../constants/hair_color')
- const eyes_color = require('../constants/eyes_color')
- const skin_color = require('../constants/skin_color').default
- const pubis = require('../constants/pubis')
- const english = require('../constants/english')
- const body = require('../constants/body')
- const baseOptions = {
- discriminatorKey: 'role',
- collection: 'users',
- };
- const Base = mongoose.model('User', new Schema(
- {
- username: {type: String, trim: true, required: true},
- age: {type: Number, max: 2001, required: true},
- city: {type: String, trim: true, required: true},
- email_management: {type: String, unique: true, trim: true, lowercase: true, required: true},
- password: {type: String, trim: true, required: true},
- terms_and_condition: {type: Date, required: true},
- newsletter: {type: Boolean},
- resetPasswordToken: {type: String},
- resetPasswordExpires: {type: Date},
- }, {
- timestamps: {
- createdAt: 'created_at',
- updatedAt: 'updated_at'
- }
- }, baseOptions,
- ));
- const Escort = Base.discriminator('escort', new Schema(
- {
- zone: {type: String, trim: true},
- phone_management: {type: Number, required: true},
- phone_public: {type: Number, required: true},
- email_public: {type: String, unique: true, trim: true, lowercase: true},
- website: {type: String, trim: true},
- about_me: {
- gender: {type: String, enum: genders, lowercase: true},
- hair_color: {type: String, enum: hair_color, lowercase: true},
- eyes_color: {type: String, enum: eyes_color, lowercase: true},
- skin_color: {type: String, enum: skin_color, lowercase: true},
- pubis: {type: String, enum: pubis, lowercase: true},
- nationality: {type: String, enum: nationalities},
- porn_actress: {type: Boolean},
- english: {type: String, enum: english, lowercase: true},
- university: {type: Boolean},
- smoker: {type: Boolean},
- body: {type: String, enum: body},
- height: {type: Number, min: 150},
- breasts: {type: Number},
- natural_breasts: {type: Boolean},
- waist: {type: Number},
- hip: {type: Number},
- weight: {type: Number, min: 45},
- description: {type: String, minlength: 250, trim: true}
- },
- rates: {
- type: Object,
- credit_card: {type: Boolean},
- services: [
- {
- service: {type: String, trim: true},
- price: {type: Number}
- }
- ]
- },
- availability: {
- type: Object,
- schedule: [
- {
- day: 'monday',
- start_time: {type: Number},
- end_time: {type: Number},
- all_day: {type: Boolean}
- },
- {
- day: 'tuesday',
- start_time: {type: Number},
- end_time: {type: Number},
- all_day: {type: Boolean}
- },
- {
- day: 'wednesday',
- start_time: {type: Number},
- end_time: {type: Number},
- all_day: {type: Boolean}
- },
- {
- day: 'thursday',
- start_time: {type: Number},
- end_time: {type: Number},
- all_day: {type: Boolean}
- },
- {
- day: 'friday',
- start_time: {type: Number},
- end_time: {type: Number},
- all_day: {type: Boolean}
- },
- {
- day: 'saturday',
- start_time: {type: Number},
- end_time: {type: Number},
- all_day: {type: Boolean}
- },
- {
- day: 'sunday',
- start_time: {type: Number},
- end_time: {type: Number},
- all_day: {type: Boolean}
- },
- ],
- home: {type: Boolean},
- romantic_dinner: {type: Boolean},
- travels: {type: Boolean},
- room_for_hours: {type: Boolean},
- exchange_clubs: {type: Boolean},
- answer_by_phone: {type: Boolean},
- hotel: {type: Boolean},
- single_party: {type: Boolean},
- apartment_escort: {type: Boolean},
- events_and_parties: {type: Boolean},
- },
- services: {
- type: Object,
- attention_women: {type: Boolean},
- kiss_mouth: {type: Boolean},
- female_ejaculation: {type: Boolean},
- full_french: {type: Boolean},
- greek: {type: Boolean},
- golden_rain: {type: Boolean},
- position_69: {type: Boolean},
- relationship_girlfriend: {type: Boolean},
- attention_couples: {type: Boolean},
- double_penetration: {type: Boolean},
- facial: {type: Boolean},
- french_with_condom: {type: Boolean},
- erotic_toys: {type: Boolean},
- real_lesbian: {type: Boolean},
- sadism: {type: Boolean},
- threesome: {type: Boolean},
- white_kiss: {type: Boolean},
- black_kiss: {type: Boolean},
- erotic_shower: {type: Boolean},
- fantasy_and_costumes: {type: Boolean},
- natural_french: {type: Boolean},
- kamasutra: {type: Boolean},
- erotic_massage: {type: Boolean},
- strap_on: {type: Boolean},
- duplex: {type: Boolean},
- fetish: {type: Boolean},
- deep_throat: {type: Boolean},
- lingerie: {type: Boolean},
- orgies: {type: Boolean},
- striptease: {type: Boolean},
- },
- photos: Array,
- }
- ));
- const Agency = Base.discriminator('agency', new Schema({
- zone: {type: String, trim: true},
- phone_management: {type: Number, required: true},
- phone_public: {type: Number, required: true},
- email_public: {type: String, unique: true, trim: true, lowercase: true},
- website: {type: String, trim: true},
- escorts: {type: Array},
- }),
- );
- const User = Base.discriminator('client', new Schema(
- {
- favorites: {type: Array},
- }
- ));
- Base.pre('save', function (next) {
- const user = this;
- if (!user.isModified('password')) return next();
- bcrypt.genSalt(config.SALT_FACTOR, function (err, salt) {
- if (err) return next(err);
- bcrypt.hash(user.password, salt).then(function(hash) {
- if (err) return next(err);
- user.password = hash;
- next();
- });
- });
- });
- module.exports = {Base, Escort, Agency, User}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement