Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Meteor lack the concept of well-defined data entity Models?

Tags:

meteor

So, today was my second day learning Meteor.js - reading documentation, watching videos, etc... What I did not see so far, was a strong concept of model, in a way that it would be used in most other JS frameworks. For example, if my Meteor app was to keep a list of people, I would declare a Collection of People, and, subsequently, add/update/remove Records to it. This to me is different from creating a Person object, setting its properties, adding that object to a collection of other Person objects, etc... Is my initial perception correct, and Meteor does not really have this paradigm of modeling business entities in a way that other frameworks do?

like image 876
Eugene Goldberg Avatar asked Apr 05 '14 03:04

Eugene Goldberg


1 Answers

Yes, that's correct. This is a parallel to the schemaless nature of MongoDB, as opposed to a RDBMS where your data tables have an explicitly defined schema. Here's a quote from the Meteor docs under new Meteor.Collection():

Calling this function is analogous to declaring a model in a traditional ORM (Object-Relation Mapper)-centric framework.

However, Meteor does not prevent you from implementing your own more fully-fledged model system on top of the existing collection system. There are quite a few 3rd party packages on atmosphere.meteor.com that are attempting to do this. The transform option on Meteor collections gives a good starting point for creating a model layer, allowing you to add behavior and virtual fields to documents when they are retrieved from the database.

Here's a roadmap entry showing that models, schemas, validators, and migrations are planned in the future for Meteor. This is essential for future SQL support. For 1.0 however, they are trying to release a stable, thin core built on top of MongoDB. The MDG is no doubt watching the current model implementations on Atmosphere for inspiration to create their own core implementation later. Geoff Schmidt briefly addressed this in the Getting Meteor to 1.0 video.

TL;DR: Meteor provides the basic, essential APIs needed to implement models for MongoDB however you want. A more well-defined official data entity system and SQL support are planned for the future, but for now you can use 3rd party solutions on Atmosphere or roll your own.

like image 108
sbking Avatar answered Nov 09 '22 22:11

sbking