CREATE REVIEW (STEP-1)
A REVIEW SECTION IS CREATED IN SHOW.EJS
<hr />
<div class="col-8 offset-2 mb-2 mt-3">
<h4>Leave a Review!</h4>
<form>
<div class="col-8 offset-2 mb-2 mt-3">
<label for="rating" class="form-label">Rating</label>
<input
type="range"
min="1"
max="5"
id="rating"
name="reivew[rating]"
class="form-range"
/>
</div>
<div class="col-8 offset-2">
<textarea
name="reivew[comment]"
id="comment"
rows="5"
cols="30"
class="form-control"
></textarea>
</div>
<button class="btn btn-outline-dark offset-2 mb-2 mt-3">submit</button>
</form>
</div>
THE SCHEMA FOR REVIEWconst mongoose = require("mongoose");
const Schema = mongoose.Schema;
const reviewSchema = new Schema({
comment: String,
rating: {
type: Number,
min: 1,
max: 5,
},
createdAt: {
type: Date,
default: Date.now(),
},
});
module.exports = mongoose.model("Review", reviewSchema);
Comments
Post a Comment