Mongoose set default as empty object

By default (in an effort to minimize data stored in MongoDB), Mongoose will not save empty objects to your database. You can override this behavior by setting the minimize flag to false when you create your schema. For example:

const schema = new Schema({
  star_info: { type: Schema.Types.Mixed, default: {} }
}, { minimize: false })

Now star_info will default to an empty object and save to the database.

Read more at http://mongoosejs.com/docs/guide.html#minimize

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)