jagi / meteor-astronomy

Model layer for Meteor
https://atmospherejs.com/jagi/astronomy
MIT License
604 stars 67 forks source link

Getting field definition #717

Closed meecect closed 4 years ago

meecect commented 4 years ago

I see I can get:

MyClassName.definition.fields.myFieldName

Is that the recommended way to do it? Is there a way to do it from the class instance? In general, is it possible to get the Class object from the instance?

Basically, I would like to do something like:

thing = new Thing({some data});

thing.getDefinition().fields['somefield'];
lukejagodzinski commented 4 years ago

You can do:

const thing = new Thing({/* data */});
thing.constructor.getFields();
thing.constructor.getField("somefield");
meecect commented 4 years ago

perfect, thanks.