Model vs. instance vs. records


#1

Is it just me, or is there confusion in the documentation regarding models, instances, and records? Its seems like it gets used interchangeably in the documentation.

For example the model hook is really a record(s) hook isn’t it? I mean you are in now way specifying the class, just the data instances being dealt with…

Interested in people’s thoughts on this


#2

model is a synonym for content. So, it can be everything you need for your route. It can be a record or some Ember Objects or even some Javascript objects. Normally you shouldnt concern yourself too much with instanciation (hope thats the right wording). Ember.data should do that for you. The only exception maybe is the createRecord method. If you are working without Ember data/model its different of course. I think thats why its confusing when reading the docs.


#3

well right, I agree and I understand, but the point is that this is presented in a very confusing and inconsistent fashion which makes it hard when you are first coming into Ember.

For example (I am taking all these from the documentation)

A model is a class that defines the properties and behavior of the data that you present to the user. (sounds about right!)

After you have defined a model class, you can start finding and creating records of that type. (also so far so good, except model class is redundant)

Now we have elsewhere:

Templates in your application are backed by models.

So if put this together I get this sentence:

Templates in your application are backed by … a class that defines the properties and behavior of the data that you present to the user.

Okay I can accept that, and it seems reasonable… the template needs a class that it will use. But that does not really seem to be what is going on. After all if that was the case then how does the template get the actual records, if all I am specifying is the model (and per other statements the model and records are two entities.)

What I think is going on here is this:

The router (and template) is can create a class if provided by specific instance data (in the example) and then treat that instance data as the specific records.

If something like this.store.find(‘person’, 1) is being returned by the model hook then what is going on here is that you are getting back a subclass of the person model that will only contain 1 instance.

Once you get it, it all begins to make sense, but its just that people are coming from different OO backgrounds, so some extra help would be good.

But that is just my guess trying to put it all together.

I am just suggesting that unless I am missing something some clarity would help people with experience in other systems to catch on quicker.