spiral / app

Spiral Framework Skeleton HTTP Application: Queue, Console, Cycle ORM
https://spiral.dev/
MIT License
191 stars 20 forks source link

How to select columns in Repository #25

Closed sujit-baniya closed 4 years ago

sujit-baniya commented 4 years ago

I want to hide some columns for some entities.

class UserRepository extends Repository implements ActorProviderInterface
{
    public function getActor(TokenInterface $token): ?object
    {
        if (!isset($token->getPayload()['userID'])) {
            return null;
        }

        return $this->findByPK($token->getPayload()['userID']);
    }
}

How would I hide the columns or add extra columns

wolfy-j commented 4 years ago

If you want to select partial models you have 2 options: 1) use Embeddings 2) use buildQuery of select and then call columns method, you will switch from ORM to DBAL