| 145 | }) |
| 146 | |
| 147 | const nativeLayer = (config: Config) => |
| 148 | Layer.effect( |
| 149 | Sqlite.Native, |
| 150 | Effect.gen(function* () { |
| 151 | const native = new DatabaseSync(config.filename, { |
| 152 | readOnly: config.readonly, |
| 153 | timeout: config.timeout, |
| 154 | allowExtension: config.allowExtension, |
| 155 | enableForeignKeyConstraints: true, |
| 156 | open: true, |
| 157 | }) |
| 158 | yield* Effect.addFinalizer(() => Effect.sync(() => native.close())) |
| 159 | if (config.disableWAL !== true && config.readonly !== true) native.exec("PRAGMA journal_mode = WAL;") |
| 160 | return native |
| 161 | }), |
| 162 | ) |
| 163 | |
| 164 | const sqliteLayer = (config: Config) => Layer.effect(Client.SqlClient, make(config)) |
| 165 | |