File size: 2,520 Bytes
7b850b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import * as mongoose from 'mongoose';
import { Document } from 'mongoose';
import { USERS } from 'src/constants';

export interface IUserDocument extends Document {
  name?: string;
  username?: string;
  email?: string;
  avatar?: string;
  isActive?: boolean;
  isDeleted: boolean;
  createdAt?: Date;
  updatedAt?: Date;
  deletedAt?: Date;
  roles?: Array<string>;
  password?: string;
  session_id?: number;
  login_location?: string;
  preferred_location?: string;
  preferred_listing_type?: string;
  property_id?: string;
  page_visit_duration?: number;
  carousel_button_click_result_page?: number;
  next_image_clicks_listing_page?: number;
  read_more_click_result_page?: number;
  read_more_click_listing_page?: number;
  clicked_more_pictures?: number;
  click_rate?: number;
  bounce?: number;
  title?: string;
  price?: string;
  bedrooms_?: string;
  bathrooms?: string;
  living_space_sqm?: string;
  pool_?: number;
}

const UserSchema = new mongoose.Schema<IUserDocument>(
  {
    name: { type: String },
    username: { type: String },
    email: { type: String, unique: true },
    avatar: { type: String },
    isActive: { type: Boolean, default: true },
    isDeleted: { type: Boolean, default: false },
    roles: [{ type: String, required: true, default: 'user' }],
    password: { type: String, required: false },
    // New fields added from IUserDocument
    session_id: { type: Number },
    login_location: { type: String },
    preferred_location: { type: String },
    preferred_listing_type: { type: String },
    property_id: { type: String },
    page_visit_duration: { type: Number, default: 0 },
    carousel_button_click_result_page: { type: Number, default: 0 },
    next_image_clicks_listing_page: { type: Number, default: 0 },
    read_more_click_result_page: { type: Number, default: 0 },
    read_more_click_listing_page: { type: Number, default: 0 },
    clicked_more_pictures: { type: Number, default: 0 },
    click_rate: { type: Number, default: 0 },
    bounce: { type: Number, default: 0 },
    title: { type: String },
    price: { type: String },
    bedrooms_: { type: String },
    bathrooms: { type: String },
    living_space_sqm: { type: String },
    pool_: { type: Number },

    createdAt: { type: Date, default: Date.now },
    updatedAt: { type: Date, default: Date.now },
    deletedAt: { type: Date },
  },
  {
    toJSON: { versionKey: false },
  },
);

export { UserSchema };