Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const mongoose = require('mongoose');
  2. const Schema   = mongoose.Schema;
  3. const nationalities = require('../constants/nationalities')
  4. const genders = require('../constants/gender')
  5. const hair_color = require('../constants/hair_color')
  6. const eyes_color = require('../constants/eyes_color')
  7. const skin_color = require('../constants/skin_color').default
  8. const pubis = require('../constants/pubis')
  9. const english = require('../constants/english')
  10. const body = require('../constants/body')
  11.  
  12. const baseOptions = {
  13.   discriminatorKey: 'role',
  14.   collection: 'users',
  15. };
  16.  
  17. const Base = mongoose.model('User', new Schema(
  18.   {
  19.     username: {type: String, trim: true, required: true},
  20.     age: {type: Number, max: 2001, required: true},
  21.     city: {type: String, trim: true, required: true},
  22.     email_management: {type: String, unique: true, trim: true, lowercase: true, required: true},
  23.     password: {type: String, trim: true, required: true},
  24.     terms_and_condition: {type: Date, required: true},
  25.     newsletter: {type: Boolean},
  26.     resetPasswordToken: {type: String},
  27.     resetPasswordExpires: {type: Date},
  28.   }, {
  29.     timestamps: {
  30.       createdAt: 'created_at',
  31.       updatedAt: 'updated_at'
  32.     }
  33.   }, baseOptions,
  34. ));
  35.  
  36. const Escort = Base.discriminator('escort', new Schema(
  37.   {
  38.     zone: {type: String, trim: true},
  39.     phone_management: {type: Number, required: true},
  40.     phone_public: {type: Number, required: true},
  41.     email_public: {type: String, unique: true, trim: true, lowercase: true},
  42.     website: {type: String, trim: true},
  43.  
  44.     about_me: {
  45.       gender: {type: String, enum: genders, lowercase: true},
  46.       hair_color: {type: String, enum: hair_color, lowercase: true},
  47.       eyes_color: {type: String, enum: eyes_color, lowercase: true},
  48.       skin_color: {type: String, enum: skin_color, lowercase: true},
  49.       pubis: {type: String, enum: pubis, lowercase: true},
  50.       nationality: {type: String, enum: nationalities},
  51.       porn_actress: {type: Boolean},
  52.       english: {type: String, enum: english, lowercase: true},
  53.       university: {type: Boolean},
  54.       smoker: {type: Boolean},
  55.       body: {type: String, enum: body},
  56.       height: {type: Number, min: 150},
  57.       breasts: {type: Number},
  58.       natural_breasts: {type: Boolean},
  59.       waist: {type: Number},
  60.       hip: {type: Number},
  61.       weight: {type: Number, min: 45},
  62.       description: {type: String, minlength: 250, trim: true}
  63.     },
  64.  
  65.     rates: {
  66.       type: Object,
  67.       credit_card: {type: Boolean},
  68.       services: [
  69.         {
  70.           service: {type: String, trim: true},
  71.           price: {type: Number}
  72.         }
  73.       ]
  74.     },
  75.  
  76.     availability: {
  77.       type: Object,
  78.       schedule: [
  79.         {
  80.           day: 'monday',
  81.           start_time: {type: Number},
  82.           end_time: {type: Number},
  83.           all_day: {type: Boolean}
  84.         },
  85.         {
  86.           day: 'tuesday',
  87.           start_time: {type: Number},
  88.           end_time: {type: Number},
  89.           all_day: {type: Boolean}
  90.         },
  91.         {
  92.           day: 'wednesday',
  93.           start_time: {type: Number},
  94.           end_time: {type: Number},
  95.           all_day: {type: Boolean}
  96.         },
  97.         {
  98.           day: 'thursday',
  99.           start_time: {type: Number},
  100.           end_time: {type: Number},
  101.           all_day: {type: Boolean}
  102.         },
  103.         {
  104.           day: 'friday',
  105.           start_time: {type: Number},
  106.           end_time: {type: Number},
  107.           all_day: {type: Boolean}
  108.         },
  109.         {
  110.           day: 'saturday',
  111.           start_time: {type: Number},
  112.           end_time: {type: Number},
  113.           all_day: {type: Boolean}
  114.         },
  115.         {
  116.           day: 'sunday',
  117.           start_time: {type: Number},
  118.           end_time: {type: Number},
  119.           all_day: {type: Boolean}
  120.         },
  121.       ],
  122.       home: {type: Boolean},
  123.       romantic_dinner: {type: Boolean},
  124.       travels: {type: Boolean},
  125.       room_for_hours: {type: Boolean},
  126.       exchange_clubs: {type: Boolean},
  127.       answer_by_phone: {type: Boolean},
  128.       hotel: {type: Boolean},
  129.       single_party: {type: Boolean},
  130.       apartment_escort: {type: Boolean},
  131.       events_and_parties: {type: Boolean},
  132.     },
  133.  
  134.     services: {
  135.       type: Object,
  136.       attention_women: {type: Boolean},
  137.       kiss_mouth: {type: Boolean},
  138.       female_ejaculation: {type: Boolean},
  139.       full_french: {type: Boolean},
  140.       greek: {type: Boolean},
  141.       golden_rain: {type: Boolean},
  142.       position_69: {type: Boolean},
  143.       relationship_girlfriend: {type: Boolean},
  144.       attention_couples: {type: Boolean},
  145.       double_penetration: {type: Boolean},
  146.       facial: {type: Boolean},
  147.       french_with_condom: {type: Boolean},
  148.       erotic_toys: {type: Boolean},
  149.       real_lesbian: {type: Boolean},
  150.       sadism: {type: Boolean},
  151.       threesome: {type: Boolean},
  152.       white_kiss: {type: Boolean},
  153.       black_kiss: {type: Boolean},
  154.       erotic_shower: {type: Boolean},
  155.       fantasy_and_costumes: {type: Boolean},
  156.       natural_french: {type: Boolean},
  157.       kamasutra: {type: Boolean},
  158.       erotic_massage: {type: Boolean},
  159.       strap_on: {type: Boolean},
  160.       duplex: {type: Boolean},
  161.       fetish: {type: Boolean},
  162.       deep_throat: {type: Boolean},
  163.       lingerie: {type: Boolean},
  164.       orgies: {type: Boolean},
  165.       striptease: {type: Boolean},
  166.     },
  167.  
  168.     photos: Array,
  169.   }
  170. ));
  171.  
  172. const Agency = Base.discriminator('agency', new Schema({
  173.   zone: {type: String, trim: true},
  174.   phone_management: {type: Number, required: true},
  175.   phone_public: {type: Number, required: true},
  176.   email_public: {type: String, unique: true, trim: true, lowercase: true},
  177.   website: {type: String, trim: true},
  178.   escorts: {type: Array},
  179.   }),
  180. );
  181.  
  182. const User = Base.discriminator('client', new Schema(
  183.   {
  184.     favorites: {type: Array},
  185.   }
  186. ));
  187.  
  188. Base.pre('save', function (next) {
  189.   const user = this;
  190.   if (!user.isModified('password')) return next();
  191.   bcrypt.genSalt(config.SALT_FACTOR, function (err, salt) {
  192.     if (err) return next(err);
  193.     bcrypt.hash(user.password, salt).then(function(hash) {
  194.       if (err) return next(err);
  195.       user.password = hash;
  196.       next();
  197.     });
  198.   });
  199. });
  200.  
  201. module.exports = {Base, Escort, Agency, User}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement