Skip to content

Commit

Permalink
Remove clean options
Browse files Browse the repository at this point in the history
  • Loading branch information
harryadel committed Dec 24, 2023
1 parent b1ed456 commit 8b4b130
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 58 deletions.
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,26 +361,6 @@ instance for a Mongo.Collection instance. For example:
MyCollection.simpleSchema().validate(doc);
```

## Schema Clean Options

You can set the simpl-schema clean options globally in collection2. They are merged with any options defined on the schema level.

```js
import Collection2 from 'meteor/aldeed:collection2'

// The values shown are the default options used internally. Overwrite them if needed.
Collection2.cleanOptions = {
filter: true,
autoConvert: true,
removeEmptyStrings: true,
trimStrings: true,
removeNullsFromArrays: true,
}

// Or you can update individual options.
Collection2.cleanOptions.filter = false;
```

## Passing Options

In Meteor, the `update` function accepts an options argument. Collection2 changes the `insert` function signature to also accept options in the same way, as an optional second argument. Whenever this documentation says to "use X option", it's referring to this options argument. For example:
Expand Down
9 changes: 0 additions & 9 deletions package/collection2/collection2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ const SimpleSchema = require('simpl-schema').default;
// Exported only for listening to events
const Collection2 = new EventEmitter();

Collection2.cleanOptions = {
filter: true,
autoConvert: true,
removeEmptyStrings: true,
trimStrings: true,
removeNullsFromArrays: false
};

/**
* Mongo.Collection.prototype.attachSchema
Expand Down Expand Up @@ -472,8 +465,6 @@ function doValidate(collection, type, args, getAutoValues, userId, isFromTrusted
schema.clean(doc, {
mutate: true, // Clean the doc/modifier in place
isModifier: !isInsertType(type),
// Start with some Collection2 defaults, which will usually be overwritten
...Collection2.cleanOptions,
// The extent with the schema-level defaults (from SimpleSchema constructor options)
...(schema._cleanOptions || {}),
// Finally, options for this specific operation should take precedence
Expand Down
29 changes: 0 additions & 29 deletions tests/defaultCleanOptions.tests.js

This file was deleted.

0 comments on commit 8b4b130

Please sign in to comment.