Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Mongoose make Object required

const extraDataSchema = new mongoose.Schema({
  brand: {
    type: String,
    required: true,
    minlength: 1,
    maxlength: 255
  },
  quantity: {
    type: Number,
    required: true,
    minlength: 1,
    maxlength: 10
  }
});

const productSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
    minlength: 1,
    maxlength: 255
  },
  extraData: {
    type: extraDataSchema, required: true
  }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Mongoose #Object #required
ADD COMMENT
Topic
Name
7+3 =