Last active
August 17, 2020 09:39
-
-
Save viktorfa/da283a1381aaa6db8e7e89570ec5b08f to your computer and use it in GitHub Desktop.
Database config for Strapi in Lambda with SQLite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// config/database.js | |
const getDatabaseConfig = ({ env }) => { | |
if ( | |
env("IS_OFFLINE", null) === "true" || | |
env("LAMBDA_RUNTIME_DIR", null) === null | |
) { | |
// In local simulated Lambda or normal Strapi | |
return { | |
connector: "bookshelf", | |
settings: { | |
client: "sqlite", | |
filename: env("DATABASE_FILENAME", ".tmp/data.db"), | |
}, | |
options: { | |
useNullAsDefault: true, | |
}, | |
}; | |
} else { | |
// In Lambda on AWS | |
return { | |
connector: "bookshelf", | |
settings: { | |
client: "sqlite", | |
filename: env("DATABASE_FILENAME", "/tmp/data.db"), | |
}, | |
options: { | |
useNullAsDefault: true, | |
}, | |
}; | |
} | |
}; | |
module.exports = ({ env }) => ({ | |
defaultConnection: "default", | |
connections: { | |
default: getDatabaseConfig({ env }), | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment