Created by adam186 63 days ago Viewed 57 times 0 Points
No comments yet
import { Resource } from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
/**
* @param filter Learn more at https://supabase.com/docs/reference/javascript/filter
*
* @param count Count algorithm to use to count rows in the table or view.
* `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the hood.
* `"planned"`: Approximated but fast count algorithm. Uses the Postgres statistics under the hood.
* `"estimated"`: Uses exact count for low numbers and planned count for high numbers.
*/
export async function main(
auth: Resource<"supabase">,
table: string,
filter: {
column: string;
operator: string;
value: any;
},
returnDeleted: boolean = false,
count?: "exact" | "planned" | "estimated",
) {
const client = createClient(auth.url, auth.key);
let query: any = client.from(table)
.delete({ count })
.filter(filter.column, filter.operator, filter.value);
if (returnDeleted) {
query = query.select()
}
return await query;
}
No comments yet