Skip to content

Question: How can I delete an empty array from database? #469

@juanpmd

Description

@juanpmd

I currently have a schema definition like this:

const PeopleSchema = new SimpleSchema({
  userId: { type: String },
  interests: { type: Array, optional: true },
  'interests.$': { type: String, optional: true },
});

If the interests field comes with values, it should save the array but if the interests field is an empty array, it should not store it in the database (remove the field completely). I do this with strings perfectly but I cant get it to work with Arrays. Does anyone know how I could do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions