-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typeorm entities not working with javascript #6997
Comments
I think the documentation is incorrect. You need to pass EntitySchema objects in the entities array. const typeorm = require("typeorm")
const EntitySchema = typeorm.EntitySchema and then in the options passed to createConnection: entities: [
new EntitySchema(require("./entity/Post")),
new EntitySchema(require("./entity/Category"))
] I submitted pull request #7031 to fix the example code. |
I have a similar error with loading the entities in the orm config, but if I try your way, I get the error: EntitySchema is not a constructor. |
I have found a workaround for it. Just rename your ormconfig.json to ormconfig.js. The module detect-ts-node will detect the enviroment and according with it you config will be loaded for dev or production. #ormconfig.js
So, just build you app with |
I'm trying to create a project with typeorm with javascript, a connection works correctly, but typeorm can't find my entities.
I am following the example provided by the type documentation: https://typeorm.io/#/usage-with-javascript
app.js:
Model/TestSchema.js:
the connection is working correctly, the problem and when I run it shows me:
Error: RepositoryNotFoundError: No repository for "Category" was found. Looks like this entity is not registered in current "default" connection?
at new RepositoryNotFoundError (/app/src/error/RepositoryNotFoundError.ts:11:9)
at EntityManager.getRepository (/app/src/entity-manager/EntityManager.ts:919:19)
at Connection.getRepository (/app/src/connection/Connection.ts:346:29)
at /app/src/app.js:32:37
at processTicksAndRejections (internal/process/task_queues.js:93:5)
The text was updated successfully, but these errors were encountered: