MongoDb Schema

How to create a schema file & use it in a model explained in MongoDB - simplest Schema, also explained useful settings after schema, how to connect (bind) collections etc.

We should think about all possibly requires that help to add to DB good enough data.

P.S.
  • Remember about reusing filed validation in different schemas, f.e. e-mail filed by Subdocuments
  • At the end of a Schema added object { versionKey: false, timestamps: true },
    • timestamps
      "createdAt": "2023-04-24T08:11:22.280Z",
      "updatedAt": "2023-04-24T08:11:22.280Z"
  • How to use schema in model explained in Simplest schema, point 2