BundleWriterFactory is a factory function that creates and returns a BundleWriter based on the type of database engine being used.
(db database.Database)
| 134 | // BundleWriterFactory is a factory function that creates and returns a BundleWriter |
| 135 | // based on the type of database engine being used. |
| 136 | func BundleWriterFactory(db database.Database) (repo storage.BundleWriter) { |
| 137 | // The switch statement determines the type of database engine. |
| 138 | switch db.GetEngineType() { |
| 139 | case "postgres": |
| 140 | // If the engine type is "postgres", create and return a PostgreSQL specific BundleWriter. |
| 141 | return PQRepository.NewBundleWriter(db.(*PQDatabase.Postgres)) |
| 142 | case "memory": |
| 143 | // If the engine type is "memory", create and return a memory-based BundleWriter. |
| 144 | return MMRepository.NewBundleWriter(db.(*MMDatabase.Memory)) |
| 145 | default: |
| 146 | // For any other engine type, default to using a memory-based BundleWriter. |
| 147 | return MMRepository.NewBundleWriter(db.(*MMDatabase.Memory)) |
| 148 | } |
| 149 | } |
no test coverage detected