// NB: 📝 I have a global ModelDatabase Layer
const result = yield* Effect.tryPromise(() => {
return db.transaction((tx) => {
// Creating a temporary ModelDatabase Layer
const TxModelDatabase = Layer.succeed(ModelDatabase, tx);
// Replacing the global ModelDatabase Layer with the Temp (TxModelDatabase Layer)
const requirements_ = Layer.merge(requirements, TxModelDatabase);
const program = Effect.provide(effect, requirements_);
// because I'm using runPromise the Errors resolve to An UnknownError
// leaving me with the option of manually resolving them.
return Effect.runPromise(program);
});
});
// NB: 📝 I have a global ModelDatabase Layer
const result = yield* Effect.tryPromise(() => {
return db.transaction((tx) => {
// Creating a temporary ModelDatabase Layer
const TxModelDatabase = Layer.succeed(ModelDatabase, tx);
// Replacing the global ModelDatabase Layer with the Temp (TxModelDatabase Layer)
const requirements_ = Layer.merge(requirements, TxModelDatabase);
const program = Effect.provide(effect, requirements_);
// because I'm using runPromise the Errors resolve to An UnknownError
// leaving me with the option of manually resolving them.
return Effect.runPromise(program);
});
});