meteor-collection2
A Meteor package that extends Mongo.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
What is meteor-collection2?
A Meteor package that extends Mongo.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
Overview of meteor-collection2
What it is
meteor-collection2is a Meteor package that extends Mongo.Collection to allow attaching a schema and automatically validating documents against that schema during insert and update operations, supporting SimpleSchema, Zod, or AJV-style JSON schemas.
Key features
- Attach a schema (SimpleSchema, Zod, or AJV) to a Mongo.Collection for automatic validation on insert and update.
- Supports attaching multiple schemas to the same collection using selector-based differentiation.
- Validation is reactive on the client and automatic on both client and server.
- Provides async mutation methods (insertAsync, updateAsync, upsertAsync) for compatibility with newer Meteor versions.
- Allows bypassing validation, cleaning, or schema checks when needed.
- Offers options for field indexing, unique constraints, denyInsert, denyUpdate, autoValue, and custom validation.
Use cases
- Enforcing data integrity and security by validating client-side inserts and updates against a defined schema.
- Displaying reactive validation error messages to users without custom event handling.
- Using with aldeed:autoform to auto-generate HTML5 forms based on the collection's schema.
- Managing multiple document types in a single collection using selector-based schema validation.
Getting started
bash# For Collection2 5.x with SimpleSchema 3 (Meteor 3.1.2+)meteor add aldeed:collection2 aldeed:simple-schema@3# For Collection2 5.x with Zod 4meteor add aldeed:collection2meteor npm install zod@4
License and pricing
This package is open source under the MIT license. Pricing is not stated.
Based on the project's public README and repository metadata.