SchemaReaderFactory creates and returns a SchemaReader based on the database engine type.
(db database.Database)
| 41 | |
| 42 | // SchemaReaderFactory creates and returns a SchemaReader based on the database engine type. |
| 43 | func SchemaReaderFactory(db database.Database) (repo storage.SchemaReader) { |
| 44 | switch db.GetEngineType() { |
| 45 | case "postgres": |
| 46 | // If the database engine is Postgres, create a new SchemaReader using the Postgres implementation |
| 47 | return PQRepository.NewSchemaReader(db.(*PQDatabase.Postgres)) |
| 48 | case "memory": |
| 49 | // If the database engine is in-memory, create a new SchemaReader using the in-memory implementation |
| 50 | return MMRepository.NewSchemaReader(db.(*MMDatabase.Memory)) |
| 51 | default: |
| 52 | // For any other type, use the in-memory implementation as a default |
| 53 | return MMRepository.NewSchemaReader(db.(*MMDatabase.Memory)) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // WatcherFactory creates and returns a Watcher based on the database engine type. |
| 58 | func WatcherFactory(db database.Database) (repo storage.Watcher) { |
no test coverage detected