C3 Type of an instance


I would like to know the most accurate c3 type of an instance without using typeIdent.

For example:

asset = GenerationAssetComponent.fetch({limit:1}).objs.at(0)
asset.type().typeName() --> “GenerationAssetComponent” but I am expecting “FeedWaterPump”

because I know that that asset is a specific type of GenerationAssetComponent (a FeedWaterPump)
asset = FeedWaterPump.get(asset.id)
asset.type().typeName() --> “FeedWaterPump”


You can use the .getSpecific() API to convert it into an instance of the more specific type. Try this:

asset = GenerationAssetComponent.fetch({limit:1}).objs.at(0);
asset.getSpecific().type().typeName(); // --> "FeedWaterPump"


Note that .getSpecific() is similar to .get() in that it makes a request to the DB. But you can actually do this:

var asset = GenerationAssetComponent.getSpecific("some-id");
asset.type().typeName(); // --> "FeedWaterPump"

and asset will be an instance of FeedWaterPump