A smart package for Meteor that extends Meteor.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
Add filter
and autoConvert
options to insert/update methods. Pass false
to disable the default behavior of filtering out extra properties and autoconverting types for that insert or update operation.
When you have the insecure
package added to your app, you expect that you do not need to define allow functions. Previously, adding collection2
in addition to insecure
caused you to need to define a "remove" allow function in order to remove documents from the client. This is now fixed.
If you add prototype properties to an object in a collection transform, those properties no longer interfere with proper validation or cause errors.
Error objects that are thrown or passed to callbacks due to schema validation are now better. See the "What Happens When The Document Is Invalid?" section in the README.
- Fix index error
- Add
removeEmptyStrings
option to insert/update methods. Passfalse
to disable the default behavior of removing empty string values for that insert or update operation.
Indexing fixes
- Validation errors that are caught on the server are now reactively added back on the client.
- Custom
unique
checking is removed; we now rely entirely on the unique MongoDB index to cause errors, which we use to addnotUnique
validation errors. Because of the previous point about server validation errors being sent back to the client, this should be a transparent change. - The deprecated
Meteor.Collection2
constructor andvirtualFields
option no longer work.
A couple small changes to make sure return values and callback arguments match exactly what the original insert/update/upsert methods would do.
- Add
attachSchema
method for attaching a schema to collections created by another package, such as Meteor.users. - Ensure "notUnique" errors are added to invalidKeys, even when thrown on the server by MongoDB.
- Fixed some issues with
this
object in autoValue functions.userId
andisUpdate
were sometimes not set correctly. - Added
isFromTrustedCode
tothis
object in autoValue and custom validation functions.
autoValue
support moved to SimpleSchema. Collection2 continues to extend
with additional options so the net effect should be no noticeable changes.
Another tweak to ensure no allow/deny security confusion
Ensure that we don't turn off the insecure
package
- Fix an issue where cleaning and autoValues were not done correctly when used with a transform or virtual fields.
this.userId
is now available in your autoValue functions
- Define default error messages for Collection2-specific error types.
- Include the first validation error message with the generic "failed validation" error message.
- Fixes for blackbox and custom object support
Fix update argument mix ups, for real.
- Restore ability to do unvalidated inserts and updates on the server. This
can be done with the new
validate: false
option, or by calling myCollection._collection.insert (or update) as before. On the client, thevalidate: false
option will skip client-side validation but not server-side validation. - Arguments are no longer sometimes adjusted improperly when doing an update or upsert.
Fix virtualFields support, broken by 0.3.0
- Collection2 is now enhancing the core collection object
Meteor.Collection
instead of creating a newMeteor.Collection2
constructor.Meteor.Collection2
is still available for now but is deprecated. - There is a new
index
option for the field definition, in order to ensure an index in the real MongoDB database. Refer to the README. SmartCollection
is no longer directly supported as that package is deprecating.Offline.Collection
no longer supports schemas. This may be a temporary change. Since it is more difficult to implement this now, we have to decide whether this is worth doing. It might be better to re-implement from theoffline-data
package side.
this.value
andthis.field().value
now return the correct value when the value is an array. (Previously they returned just the first item of the array.)
- Add
this.isUpsert
boolean for use within an autoValue function - Add
this.unset()
method for use within an autoValue function. Allows you to unset any provided values when you're returningundefined
. - Fix autoValues for upserts. Previously, any autoValues were being added to the selector in addition to the modifier. This is now fixed.
- Add support for
denyInsert
anddenyUpdate
options - Add support for
autoValue
option
Deprecate some methods that are now handled by the simple-schema package, and update docs to make the code simpler in preparation for possible future enhancements.
Allow an Offline.Collection
to be passed to the constructor.
Don't throw notUnique error for null or undefined optional fields
- Add
check
dependency - Add
upsert
support - Use
transform: null
for the deny/allow callbacks
Fix unique: true
checking for validate() and validateOne()
Fix unique: true
checking for updates
Backwards compatibility fix
No changes
Backwards compatibility fix
Don't require allow functions when insecure package is in use
Fix IE<10 errors
Remove smart-collections weak dependency until weak dependencies work properly
Minor improvements to SmartCollection integration
Remove extra auto-added keys from doc in the insert deny function. Ensures that valid objects are recognized as valid on the server.
(Backwards-compatibility break!)
- Updated to use multiple validation contexts; changed API a bit
- You can now pass
smart: true
option to use a SmartCollection without pre-creating it
- Add
unique: true
support - Allow an existing SimpleSchema to be passed in to the constructor
Fixed security/data integrity issue. Upgrade as soon as possible to ensure your app is secure.