const mongoose = require("mongoose"); const { Schema } = mongoose; const propertySchema = new Schema( { askingPrice: { type: String, required: true }, description: { type: String, required: true }, address: { type: String, required: true }, title: { type: String, required: true }, img: { type: String, required: true }, }, { toJSON: { transform(doc, ret) { ret.id = ret._id; delete ret._id; delete ret.__v; }, }, } ); const Property = mongoose.model("Property", propertySchema); module.exports = Property;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter