简体   繁体   中英

mongoose schema wrong type

I have this issue where i have defined a schema like this:

 analytics: {
    visits: {
      amounts: {
        type: Array,
        default: []
      },
      dates: {
        type: Array,
        default: []
      }
    },
  },

The problem is, when i take a look into the schema its not an array, it is null

 analytics: {
    visits: {
      amounts: null,
      dates: null
    },
  },

Why is it null

According to the documentation :

specifying an empty array is equivalent to Mixed.

Try this:

analytics: {
    visits: {
      amounts: [],
      dates: []
    },
  },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM