Created
July 23, 2023 22:33
-
-
Save ashutoshpw/60cc1cd4edcefd8d86e97ead46b1059e to your computer and use it in GitHub Desktop.
App Review Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose') | |
const { toJSON, paginate, customTimeStamp } = require('./plugins'); | |
const reviewSchema = new mongoose.Schema({ | |
app_name: { | |
type: String, | |
}, | |
app_id: { | |
type: String, | |
required: true, | |
unique: true, | |
index: true, | |
}, | |
app_store: { | |
type: String, | |
enum: ['google_play_store', 'apple_app_store'], | |
required: true, | |
}, | |
app_store_review_id: { | |
type: String, | |
}, | |
app_version: { | |
type: String, | |
index: true, | |
sparse: true, | |
}, | |
author: { | |
display_name: { | |
type: String, | |
}, | |
avatar_url:{ | |
type: String, | |
} | |
}, | |
content: { | |
title: { | |
type: String, | |
}, | |
body: { | |
type: String, | |
}, | |
rating: { | |
type: Number | |
}, | |
date:{ | |
type: String, | |
}, | |
updated_at: { | |
type: Number | |
} | |
}, | |
reply: { | |
date: { | |
type: String, | |
}, | |
text: { | |
type: String, | |
} | |
}, | |
external_reply_url: { | |
type: String, | |
}, | |
store_permalink: { | |
type: String, | |
}, | |
share_url: { | |
type: String, | |
}, | |
country: { | |
type: String, | |
index: true, | |
sparse: true | |
}, | |
language: { | |
type: String, | |
index: true, | |
sparse: true | |
}, | |
source:{ | |
type: String, | |
index: true, | |
enum:['public','developer'], | |
default:'public' | |
}, | |
updated_at:{ | |
type: Number, | |
default: () => +new Date(), | |
}, | |
created_at:{ | |
type: Number, | |
default: () => +new Date(), | |
}, | |
}, { | |
timestamps: customTimeStamp, | |
}) | |
reviewSchema.plugin(toJSON) | |
reviewSchema.plugin(paginate) | |
const ReviewModel = mongoose.model('Reviews', reviewSchema); | |
module.exports = mongoose.models.Reviews || ReviewModel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment