Cannot get typeorm and mysql working
See original GitHub issueHi, I followed the examples as best I could from the documentation, but no matter what I change I get this error:
No repository for "User" was found. Looks like this entity is not registered in current "default" connection?
My database.providers.ts
file looks like this
import {userProviders} from "../UserModule/user.providers";
import {User} from "../UserModule/user.entity";
export const databaseProviders = [
{
provide: 'DbConnectionToken',
useFactory: async () => await createConnection({
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: 'root',
database: 'mydb',
entities: [
__dirname + '/../**/*.entity{.ts,.js}',
],
synchronize: true
}),
},
];
I tried putting the User
entity directly into the entities
option, but that had no effect. I’ve also fiddled with that glob string about every which way possible. I’m completely out of ideas as to what to try.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Cannot connect to a MySQL database using NestJS and ...
I am trying to create a new project using NestJS and I want to use a MySQL database with the help of TypeORM...
Read more >Caching queries - typeorm - GitBook
This will execute a query to fetch all admin users and cache the results. Next time you execute the same code, it will...
Read more >Connection Options | TypeORM Docs
get (name: string) . Connection names for different connections cannot be same - they all must be unique. If connection name is not...
Read more >TypeORM and MySql Configuration for NestJS - Medium
Introduction. Today I will try to explain different approaches to take while configuring the MySQL database with NestJS using typeorm. To get a...
Read more >SQL (TypeORM) | NestJS - A progressive Node.js framework
Since it's written in TypeScript, it works pretty well with the Nest framework. Getting started#. To start the adventure with this library we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for looking into it guys. I went through all the files again, and I finally found the discrepancy. I forgot to put the
@Entity()
annotation on theUser
object… my bad.It does feel like this should throw a more specific error, but I imagine that has nothing to do with nestjs and only with the typeorm library.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.