Simpleschema: Add empty string to mongodb

Hello @ll,

I use for my validation the “simpleschema” package. Here is the schema:

activate: {
    type: String,
    label: "ActiveID"
}

And now if I want to insert an object with “activate” key and a empty string:

Task.insert({ ... , activate: "", ...})

Meteor add all keys but not the “activate” key to the document, and I don’t know why. Please help to solve this issue.

It is a feature from Collection2 where

To skip removing empty strings, set the removeEmptyStrings option to false when you call insert or update.

A more baseline and simpleschema based option would be to use defaultValue where empty strings are not cleaned if the default value is ""

Or you can use the clean method to pass in the same option