ibrahimyaacobI
Convex Community12mo ago
6 replies
ibrahimyaacob

how do i skip indexed query field

it seems like i am forced to follow the order of the defined index in schema. I dont want to use filter because some of the query are hitting too many bytes read error. please help

schema.ts
    .index("organizationId_postedAt_experiment", [
      "organizationId",
      "isOwner",
      "statusLabel",
      "postedAt",
    ])


function.ts
let query = ctx
      .table(
        "socialPostComments",
        "organizationId_postedAt_experiment",
        (q) => {
          let indexedQuery = q
            .eq("organizationId", args.organizationId)
            .eq("isOwner", false) // i want to skip this, make it optional
            .eq("statusLabel", "LIVE");

          if (args.date) {
            return indexedQuery
              .gte("postedAt", args.date.from)
              .lte("postedAt", args.date.to);
          }

          return indexedQuery;
        },
      )
      .order("desc");
Was this page helpful?