loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.94k stars 1.06k forks source link

Defining virtual fields in models (linked to a mysql datasource) #2013

Closed pepsivontwist closed 5 years ago

pepsivontwist commented 5 years ago

Hi,

Having trouble handling a hasMany relation. So, I have Product -> Has Many -> Properties

I've defined the productId property on the Properties model; Defined the hasMany decorator on the 'properties' field of the Product model.

Updated the Product repository to handle assignment via a HasManyRepositoryFactory. Only issue now is that the automigration creates a "properties" TEXT field on the Product table. (MySQL).

Any idea how I could define it as purely virtual?

Thanks!

b-admike commented 5 years ago

Hi @overburn, this should be fixed by #2167 in the latest release (https://github.com/strongloop/loopback-next/releases/tag/%40loopback%2Frepository%401.1.3). Feel free to re-open if you still see this issue.