How to define object in array in Mongoose schema correctly with 2d geo index

前端 未结 4 755
故里飘歌
故里飘歌 2020-12-04 06:35

I\'m currently having problems in creating a schema for the document below. The response from the server always returns the \"trk\" field values as [Object]. Somehow I have

4条回答
  •  庸人自扰
    2020-12-04 07:04

    I had a similar issue with mongoose :

    fields: 
        [ '[object Object]',
         '[object Object]',
         '[object Object]',
         '[object Object]' ] }
    

    In fact, I was using "type" as a property name in my schema :

    fields: [
        {
          name: String,
          type: {
            type: String
          },
          registrationEnabled: Boolean,
          checkinEnabled: Boolean
        }
      ]
    

    To avoid that behavior, you have to change the parameter to :

    fields: [
        {
          name: String,
          type: {
            type: { type: String }
          },
          registrationEnabled: Boolean,
          checkinEnabled: Boolean
        }
      ]
    

提交回复
热议问题