All what depository does it to forward the calls to EM, so the only real difference is that it bares the entity name for you. Check the source code, its really just about that:
// this is equalconsta1=awaitem.findOne(Author,1);consta2=awaitem.getRepository(Author).findOne(1);
So the benefit is that the API is simpler (no need to pass the entity name), and that repositories are an extension point - you can implement your own and add more methods there.
And no, there is no active record support and it never will be - I don't think it could even work.
class User extends EntityManage {
}
User.findOne(User, 1)
I'm asking this because instead of importing em each time you want to access an Entity would be cumbersome. Instead, I can just extend its static methods.
All what depository does it to forward the calls to EM, so the only real difference is that it bares the entity name for you. Check the source code, its really just about that:
github.com/mikro-orm/mikro-orm/blo...
So the benefit is that the API is simpler (no need to pass the entity name), and that repositories are an extension point - you can implement your own and add more methods there.
And no, there is no active record support and it never will be - I don't think it could even work.
But still I can use the
EntityManager
like:I'm asking this because instead of importing
em
each time you want to access an Entity would be cumbersome. Instead, I can just extend its static methods.Thank you for the great response sir.
No, as I said, this is not supported. You need to have an instance of entity manager (one per each request) as it holds the state (identity map).