1

this is the schema that i want to be flexible :

const mongoose = require("mongoose");
const { Schema } = mongoose;
const schema = new Schema(
  {
    //something goes here
  },
  {
    timestamps: true,
  }
);

const newModel =  mongoose.model("Trash", schema);

Now suppose this the trick that I want to do

newModel.create({
    name: "name1",
    age: 24
})

newModel.create({
    name: "name1",
    age: 24,
    address: "address",
    phone: 425565634
})

//and more....
Fraser
  • 15,275
  • 8
  • 53
  • 104
  • 1
    [Does this answer your question?](https://stackoverflow.com/questions/24942037/mongoose-schema-optional-fields) – Fraser Nov 05 '22 at 11:55

0 Answers0