Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Retational tables based on object types

Is it possible to have a "hasMany" relationship depended on a column value?

IE

users (has-many) id | data | ...

$this->hasMany("id", "files", "objectId", array(
    'alias' => 'userFiles'));
        // is there some way to add some type of if type ="users" 

customers (has-many) id | data | ...

$this->hasMany("id", "files", "objectId", array(
    'alias' => 'customerFiles'));
    // is there some way to add some type of if type ="customer" 

files (belongs-to) id | type | objectId | data

$this->belongsTo(/* ??? */);


33.7k
Accepted
answer

HA great timing it just released.