(
Model: S,
options: {
readonly tableName: string
readonly spanPrefix: string
readonly idColumn: Id
readonly softDeleteColumn?: SoftDelete | undefined
}
)
| 228 | * @since 4.0.0 |
| 229 | */ |
| 230 | export const makeResolvers = < |
| 231 | S extends Model.Any, |
| 232 | Id extends (keyof S["Type"]) & (keyof S["update"]["Type"]) & (keyof S["fields"]), |
| 233 | SoftDelete extends keyof S["fields"] = never |
| 234 | >( |
| 235 | Model: S, |
| 236 | options: { |
| 237 | readonly tableName: string |
| 238 | readonly spanPrefix: string |
| 239 | readonly idColumn: Id |
| 240 | readonly softDeleteColumn?: SoftDelete | undefined |
| 241 | } |
| 242 | ): Effect.Effect< |
| 243 | { |
| 244 | readonly insert: RequestResolver.RequestResolver< |
| 245 | SqlResolver.SqlRequest< |
| 246 | S["insert"]["Type"], |
| 247 | S["Type"], |
| 248 | ResultLengthMismatch | SqlError, |
| 249 | S["insert"]["EncodingServices"] |
| 250 | > |
| 251 | > |
| 252 | readonly insertVoid: RequestResolver.RequestResolver< |
| 253 | SqlResolver.SqlRequest<S["insert"]["Type"], void, SqlError, S["insert"]["EncodingServices"]> |
| 254 | > |
| 255 | readonly findById: RequestResolver.RequestResolver< |
| 256 | SqlResolver.SqlRequest< |
| 257 | S["fields"][Id]["Type"], |
| 258 | S["Type"], |
| 259 | Cause.NoSuchElementError | SqlError, |
| 260 | S["DecodingServices"] | S["fields"][Id]["EncodingServices"] |
| 261 | > |
| 262 | > |
| 263 | readonly delete: RequestResolver.RequestResolver< |
| 264 | SqlResolver.SqlRequest< |
| 265 | S["fields"][Id]["Type"], |
| 266 | void, |
| 267 | SqlError, |
| 268 | S["fields"][Id]["EncodingServices"] |
| 269 | > |
| 270 | > |
| 271 | }, |
| 272 | never, |
| 273 | SqlClient | Scope |
| 274 | > => |
| 275 | Effect.gen(function*() { |
| 276 | const sql = yield* SqlClient |
| 277 | const idSchema = Model.fields[options.idColumn] |
| 278 | const idColumn = options.idColumn as string |
| 279 | const softDeleteColumn = options.softDeleteColumn as string | undefined |
| 280 | const withSoftDeleteFilter = (where: any) => |
| 281 | softDeleteColumn === undefined ? where : sql.and([where, sql`${sql(softDeleteColumn)} is null`]) |
| 282 | const setSoftDeleted = softDeleteColumn === undefined |
| 283 | ? undefined |
| 284 | : sql`${sql(softDeleteColumn)} = CURRENT_TIMESTAMP` |
| 285 | |
| 286 | const insert: RequestResolver.RequestResolver< |
| 287 | SqlResolver.SqlRequest< |
nothing calls this directly
no test coverage detected