export const insertIntoTable = async ({
client,
data,
tableName,
}: InsertArgs) =>
Effect.runPromise(
Effect.tryPromise(async () => {
const resp = await client.from(tableName).insert(data);
if (resp.error) {
console.error(
`An error occurred while inserting a table entry:`,
resp.error
);
// Also as a side note, where does Effect.fail usually propogate to? For me in this scenario it seems like the errors just never appear, but I'm sure it's user error on my part
return Effect.fail(resp.error);
} else {
return Effect.succeed(resp.data);
}
})
);
export const insertIntoTable = async ({
client,
data,
tableName,
}: InsertArgs) =>
Effect.runPromise(
Effect.tryPromise(async () => {
const resp = await client.from(tableName).insert(data);
if (resp.error) {
console.error(
`An error occurred while inserting a table entry:`,
resp.error
);
// Also as a side note, where does Effect.fail usually propogate to? For me in this scenario it seems like the errors just never appear, but I'm sure it's user error on my part
return Effect.fail(resp.error);
} else {
return Effect.succeed(resp.data);
}
})
);