typeorm / ionic-example

Example project to demonstrate TypeORM in an Ionic app
67 stars 56 forks source link

Provide connection through angular di #15

Closed davidmpaz closed 6 years ago

davidmpaz commented 6 years ago

Hi,

thanks for this example project, has help me a lot already. I am making this PR since I stumble with issue typeorm/typeorm#1335 while trying to provide my connection through angular DI mechanism.

The old approach of using a provider mentioned in this thread helped, but still we not exactly the same as providing the connection itself. I did came up with this solution.

My request is to add this PR into another branch and make references in docs, so we have another example under the belt.

best regards.

Commit msg Delegate the creation of the connection to the factory function. Allow to inject the connection into components through @Inject().

Changes:

daniel-lang commented 6 years ago

Thank you for your PR but I don't see a benefit in having this. You can call getConnection() or getRepository() in any file of your project without depending on any DI.

davidmpaz commented 6 years ago

Agreed.

I made it because that's what I wanted to avoid. Just taste thing I would say.

pleerock commented 6 years ago

I guess this can be closed?

davidmpaz commented 6 years ago

yeap