RepositoryNotFoundError w/ serverless offline
See original GitHub issueIssue type: [x] bug report
Database system/driver:
[x] postgres
TypeORM version:
[x] 0.2.7
(or put your version here)
Steps to reproduce or a small repository showing the problem:
- Use ormconfig.json, set entities to something like
"**/entities/*.{js,.ts}"
- Run
serverless offline start
- Try to get repo like:
this.repo = connection.getRepository<User>(User)
- I also tried like
this.repo = connection.getRepository<User>('User')
Result: RepositoryNotFoundError: No repository for “User” was found. Looks like this entity is not registered in current “dev” connection?
I know my entities are set correctly in my ormconfig.json file b/c my database tables are all synced correctly, but I can’t get a repo to do any work.
Please help!
Here’s my ormconfig.json:
{
"name": "dev",
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "postgres",
"database": "postgres",
"entities": [
"**/entities/*.{js,.ts}"
],
"synchronize": true,
"logging": false
}
Here’s what my Database class looks like:
export class Database {
private connectionManager: ConnectionManager
constructor() {
Logger.info(`Database()`)
this.connectionManager = getConnectionManager()
}
public async getConnection(): Promise<Connection> {
Logger.info(`Database.getConnection()`)
let connection: Connection
try {
connection = this.connectionManager.get(process.env.CONNECTION_NAME)
}
catch (e) {
Logger.warn(`Database.getConnection()-error=${e}`)
// read connection options from ormconfig file (or ENV variables)
const connectionOptions = await getConnectionOptions(process.env.CONNECTION_NAME);
Object.assign(connectionOptions, { namingStrategy: new SnakeNamingStrategy() });
Logger.info(`Database.getConnection()-connectionOptions=${inspect(connectionOptions)}`)
connection = await createConnection(connectionOptions)
}
return connection
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
No error on ts-node-dev script, but errors occurred on ...
I'm making serverless project with using node, koa, typescript, ... \typeorm\error\RepositoryNotFoundError.js:11:1) at EntityManager.
Read more >Serverless offline plugin
Serverless Offline. This Serverless plugin emulates AWS λ and API Gateway on your local machine to speed up your development cycles.
Read more >serverless-offline/community - Gitter
I'm using serverless-offline 6.5.0 in my project, and want to test my functions which don't have an HTTP events with invocation endpoint (via...
Read more >Developing locally with Serverless Offline | Reason SLS
Create a Serverless function using slspress. In this tutorial, we are gonna use serverless-offline to create and run Serverless offline.
Read more >Serverless - FAQ | NestJS - A progressive Node.js framework
With a serverless architecture, you focus purely on the individual functions in your ... aws-lambda $ npm i -D @types/aws-lambda serverless-offline.
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 Free
Top 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
@ganesh9596 I actually had to switch back to explicitly calling out the entities because I switched I had to minify my code (using Browserify) and after minification it no longer makes sense to have a directory structure.
But here’s my current connectionOptions for reference:
@warnerpinz https://www.npmjs.com/package/typeorm-naming-strategies