Skip to content

Base Query utility #254

Description

@patroza
const unassignedQuery1 = Time
    .use((time) =>
      pipe(
        Q.make<PickItem.Encoded>(),
        where("assignedToId", null),
        and("state.at", "gte", subDays(time.now, 5).toISOString()),
        and("state._tag", "in", ["Valid", "LabelCreated"])
      )
    )
        const q = yield* pickItemRepo.unassignedQuery1
        const items = yield* pickItemRepo
          .query(() =>
            pipe(
              q,
              Q.project(
                S.encodedSchema(S.Struct(PickItem.pick("assignedToId", "carrier", "state", "priority"))),
                "project"
              )
            )
          )

or

        const items = yield* pickItemRepo.unassignedQuery1.pipe(
          Effect.flatMap((q) =>
            pickItemRepo
              .query(() =>
                pipe(
                  q,
                  Q.project(
                    S.encodedSchema(S.Struct(PickItem.pick("assignedToId", "carrier", "state", "priority"))),
                    "project"
                  )
                )
              )
          )

would love this to be:

        const items = yield* pickItemRepo
          .unassignedQuery(
              Q.project(
                S.encodedSchema(S.Struct(PickItem.pick("assignedToId", "carrier", "state", "priority"))),
                "project"
              )
          )

so we need a utility that can define base queries;
unassignedQuery = generateBaseQuery(...)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions