const program = Effect.gen(function* ($) {
const data: DataModel[] = yield* $(Effect.succeed(expected));
const cached: Option.Option<DataModel[]> = yield* $(cache(data));
// Start
//Better way to handle this option case and early return?
const models = pipe(
cached,
Option.getOrElse(() => []),
) satisfies DataModel[];
if (models.length === 0) {
return Effect.unit();
}
// end
return yield* $(
Effect.all(DatabaseTag, SchemaTag),
Effect.flatMap(([database, schema]) => interpreter({ db: database, modelToSchemaMap: schema }, models)),
);
});
const program = Effect.gen(function* ($) {
const data: DataModel[] = yield* $(Effect.succeed(expected));
const cached: Option.Option<DataModel[]> = yield* $(cache(data));
// Start
//Better way to handle this option case and early return?
const models = pipe(
cached,
Option.getOrElse(() => []),
) satisfies DataModel[];
if (models.length === 0) {
return Effect.unit();
}
// end
return yield* $(
Effect.all(DatabaseTag, SchemaTag),
Effect.flatMap(([database, schema]) => interpreter({ db: database, modelToSchemaMap: schema }, models)),
);
});