Skip to content

Instantly share code, notes, and snippets.

@snehil002
Created January 25, 2023 11:04
Show Gist options
  • Save snehil002/8a493d91acfca6ea9b346f8a0a08e12e to your computer and use it in GitHub Desktop.
Save snehil002/8a493d91acfca6ea9b346f8a0a08e12e to your computer and use it in GitHub Desktop.
Web AnalyticsTool - MongoDB Schema Design - Fields and Validations
/***********Mongoose Schema*********/
const sessionSchema = new Schema({
"webId": {
type: String,
enum: { values: ["SUB001"], message: "{VALUE} is not Valid!" },
required: [true, "Why no WEB ID?"]
},
"currentUrlHost": { type: String, required: [true, "Why no URL Orgin?"] },
"currentPagePath": { type: String, required: [true, "Why no Page Path?"] },
"visiOrOpenDateTime": { type: Date, required: [true, "Why no Page Visit Date?"] },
"timeOnPageInS": {
type: Number,
min: [0, "Negative time duration!"],
required: [true, "Why no Time Spent on Page?"]
},
"trafficSource": { type: String, required: [true, 'Why no Traffic Source?'] },
"deviceWidth": {
type: Number,
min: [100, "Screen width too small!"],
max: [10500, "Screen width so large!"],
required: [true, 'Why no Device Width?']
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment