D
D
Dimash Kenzhegaliev2021-12-05 03:28:56
Mongoose
Dimash Kenzhegaliev, 2021-12-05 03:28:56

How to make mongoDB not create empty fields by default?

Here is an example of such a scheme:

name: {
    type: String,
    required: true
  },
  questionType: {
    type: String
  },
  cleanFields: [String],
  field: {
    type: String
  },
  requests: [
    {
      url: {
        type: String
      },
      method: {
        type: String
      },
      postData: {
        type: Object
      },
      setResponseData: {
        type: Object
      }
    }
  ],

and when creating this object, I can not specify the requests parameter,
but even when I don’t specify it at all, it still creates an empty requests array
, can I fix this somehow?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question