-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
issue: feature requestIssue suggesting a new featureIssue suggesting a new feature
Description
Bug report
Required System information
- Node.js version: v18.14.2
- Yarn version: 1.22.19
- Strapi version: 4.14.4
- Database: postgres
- Operating system: darwin-arm64
- Is your project Javascript or Typescript: Typescript
Describe the bug
Knex supports dynamic database connection by providing a function for the database connection config. It's been noted that the data inside of the strapi db config is passed directly to knex however when I use a function for the strapi db connection config, I get the following error
TypeError: Cannot read properties of undefined (reading 'schema')
from the getSchemaName() function resulting in a failed startup.
The issue is that this.connection.client.connectionSettings is undefined when providing a function as the connection config.
Steps to reproduce the behavior
- Provide a function as the strapi db connection config. i.e.
export default ({ env }) => ({
connection: {
client: 'postgres',
connection: async () => {
const {
token,
tokenExpiration
} = await someCallToGetTheToken();
return {
host : 'your_host',
port : 5432,
user : 'your_database_user',
password : token,
database : 'myapp_test',
expirationChecker: () => {
return tokenExpiration <= Date.now();
}
};
}
}
})
- Start strapi app
Expected behavior
Strapi to support dynamic database connection via db connection config function.
Screenshots
N/A
Code snippets
N/A
Additional context
N/A
daniel-biloglav
Metadata
Metadata
Assignees
Labels
issue: feature requestIssue suggesting a new featureIssue suggesting a new feature
Type
Projects
Status
Fixed/Shipped