Back to templates

Template details

Astronomy for Meteor

Model layer for Meteor

About this template

Astronomy for Meteor (the jagi:astronomy package) is a model-layer library for the Meteor platform that turns plain MongoDB documents into schema-defined classes with field validation, change tracking, and automatic persistence.

What is Astronomy for Meteor?

Astronomy for Meteor is an Object Document Mapping (ODM) / Object-Relational Mapping (ORM) system that introduces a Model Layer to Meteor applications. It takes a MongoDB collection and a schema definition (fields, types, validators, behaviors) and produces a Class whose instances wrap documents with extra logic. The package is installed with meteor add jagi:astronomy, is developed by the GitHub user jagi, and is released under the MIT License.

Key Features

  • Schema-based class definition — Define a model with Class.create, specifying a name, a MongoDB collection, fields with types and validators, and behaviors; the schema is declared once and reused across the app.
  • Field validators — Attach validators such as minLength with a parameter value, so documents are checked before saving; the example schema rejects post titles shorter than 3 characters.
  • Automatic type conversion — Assign form input strings to typed fields (like Date or String) and Astronomy handles conversion when you call save().
  • Change tracking and partial updates — The save() method detects which fields have changed and runs an update with only the modified fields on the underlying collection.
  • Built-in behaviors — Add behaviors such as timestamp to automatically manage createdAt and updatedAt fields on each document.
  • Class-based query methods — Call Post.findOne(id) on the class instead of the raw collection, returning an instance with model logic rather than a plain object.
  • Meteor methods support — Astronomy works with Meteor methods, as noted in contributor credits.
  • Open source with documentation — Full documentation is hosted at jagi.github.io/meteor-astronomy, and weekly video tutorials are available via a linked playlist.

Who is it for?

  • Meteor application developers — Replace repetitive manual validation, field-change detection, and collection updates with a declared schema and a single save() call.
  • Teams building MongoDB-backed products — Enforce consistent field types and validation rules across clients and server by sharing the same model classes.
  • Developers coming from relational databases — Use an ORM-like structure in Meteor, mapping collections to classes with typed fields and relationships defined in one place.

What can you do with Astronomy for Meteor?

  • Define a post model with validation — Create a Post class with a title field that must be at least 3 characters, a userId, and a publishedAt date, then reuse it everywhere.
  • Auto-timestamp documents — Enable the timestamp behavior so every created and updated document gets createdAt and updatedAt values without manual assignment.
  • Simplify form handling — Read values from a form, assign them to a model instance, and let Astronomy convert and validate before persisting.

How does Astronomy for Meteor work?

Install the package with meteor add jagi:astronomy, import Class from meteor/jagi:astronomy, define a schema that names the class, points to a MongoDB collection, and declares fields plus validators, then call save() on instances. Internally the class wraps the collection's findOne, insert, and update methods to apply validation and change tracking.

FAQ

Is Astronomy for Meteor free?

Yes, the package is open source and released under the MIT License, so it is free to use in commercial and personal projects.

How do I install Astronomy for Meteor?

Run meteor add jagi:astronomy from your Meteor project directory. The package is hosted on Atmosphere, Meteor's package registry.

What does the save() method do?

save() validates all fields on the model instance according to the schema, then updates the underlying MongoDB document with only the fields that have changed, leaving unchanged fields untouched.

Does Astronomy include timestamp fields automatically?

Not by default, but the timestamp behavior can be enabled in the schema, which automatically sets createdAt and updatedAt fields.

Where can I find documentation and tutorials?

Documentation is available at jagi.github.io/meteor-astronomy, and the author publishes weekly video tutorials linked from the GitHub README.

screenshot of Astronomy for Meteor on template0.com