I am performing CRUD operations using MEAN stack. I am using mongoose and I have created a schema also.
discussions.js
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const discussionSchema = new Schema({
question: String,
date: String,
askedby: String,
answers: String[],
tags: String[]
})
module.exports = mongoose.model('discussion', discussionSchema, 'discussions');
Notice that answers and tags properties should be an array of string type while rest of the properties are simple string values. Is this the correct implementation? Please correct me.
Stringarrays in schemas can be defined as:answers: [String]. Mongoose schemas types