Skip empty list from persistence in Spring Mongo

Viewed 101

I have a Spring application that uses MongoTemplate to write to MongoDB. The problem is that I want to skip empty list entity properties from persistence to save some space around the docuemnt. How can I do that?

1 Answers

When defining your schema model, you can set default: undefined config for that property.

const schema= new Schema({
  property_1: { type: Array, default: undefined },
})
Related