Comments (7)
Can anyone help on this issue? @nodece @stu01509
from typeorm-adapter.
Can you paste your code and error message? I will get in-depth about this issue.
from typeorm-adapter.
from typeorm-adapter.
It works fine.
const a = await TypeORMAdapter.newAdapter({
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: '*******',
database: 'casbin',
dropSchema: true
});
from typeorm-adapter.
Hi, sorry for not answering. The problem may be that I am calling dropSchema using the Nestjs module. Without calling the adapter with dropSchema. So the adapter tries to access the table after it has been deleted.
Error:
[Nest] 4696 - 11/01/2020, 5:55:38 PM [ExceptionHandler] relation "casbin_rule" does not exist +440ms
QueryFailedError: relation "casbin_rule" does not exist
at new QueryFailedError (C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp\nest-backend\node_modules\typeorm\error\QueryFailedError.js:11:28)
at Query.callback (C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp\nest-backend\node_modules\typeorm\driver\postgres\PostgresQueryRunner.js:187:38)
at Query.handleError (C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp\nest-backend\node_modules\pg\lib\query.js:128:19)
at Client._handleErrorMessage (C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp\nest-backend\node_modules\pg\lib\client.js:326:17)
at Connection.emit (events.js:311:20)
at Connection.EventEmitter.emit (domain.js:482:12)
at C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp\nest-backend\node_modules\pg\lib\connection.js:109:12
at Parser.parse (C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp\nest-backend\node_modules\pg-protocol\dist\parser.js:40:17)
at Socket.<anonymous> (C:\Users\Adrian Wix\Code\posterlab\posterlab-mvp\nest-backend\node_modules\pg-protocol\dist\index.js:10:42)
at Socket.emit (events.js:311:20)
Nestjs config
TypeOrmModule.forRootAsync({
useFactory: (config: ConfigService) => {
return {
type: 'postgres',
host: config.get('DATABASE_HOST'),
port: config.get<number>('DATABASE_PORT'),
username: config.get('DATABASE_USERNAME'),
password: config.get('DATABASE_PASSWORD'),
database: config.get('DATABASE_NAME'),
entities,
logging: config.get('NODE_ENV') === 'development',
// migrationsRun: config.get('NODE_ENV') !== 'test',
dropSchema: true,
synchronize: config.get('NODE_ENV') === 'test' || true,
migrations: [
config.get('NODE_ENV') === 'test'
? join(
__dirname,
'../',
'src/database/migrations/**/*{.ts,.js}',
)
: join(
__dirname,
'database/migrations/**/*{.ts,.js}',
),
],
keepConnectionAlive: true,
}
},
inject: [ConfigService],
}),
Casbin adapter
{
provide: CASBIN_ENFORCER,
useFactory: async (config: ConfigService) => {
// TODO: Use a different connection
const adapter = await TypeORMAdapter.newAdapter({
type: 'postgres',
host: config.get('DATABASE_HOST'),
port: config.get<number>('DATABASE_PORT'),
username: config.get('DATABASE_USERNAME'),
password: config.get('DATABASE_PASSWORD'),
database: config.get('DATABASE_NAME'),
// dropSchema: true
})
// const adapter = join(process.cwd(), 'dist/iam/policy.csv')
const e = await newEnforcer(
join(process.cwd(), 'dist/iam/models/default.conf'),
adapter,
)
e.addFunction('keyMatch2', keyMatch2Func)
e.addFunction('keyMatch', keyMatchFunc)
return e
},
inject: [ConfigService],
},
EDIT: Sorry for the vague question. My brain wasn't working anymore at that hour...
from typeorm-adapter.
@adrianwix Could you try to initialize TypeORM first and then Casbin Adapter?
Maybe adding dropSchema
is not a good idea :(
from typeorm-adapter.
Closed as stale.
from typeorm-adapter.
Related Issues (20)
- batch operation support HOT 2
- Error: filtered policies are not supported by this adapter HOT 2
- Any existing function to retrieve filtered policies HOT 5
- [feat] pass connection object to newAdapter HOT 2
- AlreadyHasActiveConnectionError issue in nestjs HOT 2
- use database replace .csv get error:nodejs.AlreadyHasActiveConnectionError HOT 4
- Publish v1.3.0 to npm HOT 8
- Migrate from Travis CI to Github Actions HOT 3
- removePolicy not working HOT 1
- Limited to 6 policy arguments HOT 3
- v1.5 Performance regression HOT 3
- use ExistentConnection HOT 4
- [bug] removeFilteredPolicy is not working properly HOT 1
- The automated release is failing 🚨 HOT 2
- TypeORM adapter fails with ACL model HOT 1
- Custom database table name HOT 4
- Issue: ObjectID no longer be used in typeorm, please update to ObjectId HOT 3
- RESOLVE unable to resolve dependency tree HOT 2
- The lib directory is missing in version 1.6.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeorm-adapter.