jax
jax

Reputation: 38583

Interrogate ember-data model

Given a string like 'vehicle', I want to lookup this model and find all the field information.

For example, given a 'vehicle' string I want it to lookup the vehicle model and get the following.

FIELD                     TYPE          RELATED MODEL
registrationNumber        string        null
vehicleMake               belongsTo     manufacturer
versions                  hasMany       version

Is this possible?

Upvotes: 0

Views: 26

Answers (1)

jax
jax

Reputation: 38583

Found the solution

var modelConstructor = this.store.modelFor('vehicle');
var attributes = Ember.get(modelConstructor, 'attributes');
var relationshipNames = Ember.get(modelConstructor, 'relationshipNames');

Upvotes: 1

Related Questions