NewEngine picks the appropriate engine for the given database. isPostgres selects between PostgreSQLQueryDialect (true) and SQLiteQueryDialect (false). This is the preferred entry point for callers that have a Store with an unknown backend — pass store.IsPostgres() as the flag. The return type is t
(db *sql.DB, isPostgres bool)
| 49 | // The return type is the Engine interface so the SQLite-only TextEngine |
| 50 | // is hidden when isPostgres is true. |
| 51 | func NewEngine(db *sql.DB, isPostgres bool) Engine { |
| 52 | if isPostgres { |
| 53 | return NewPostgreSQLEngine(db) |
| 54 | } |
| 55 | return NewSQLiteEngine(db) |
| 56 | } |