Best way to "build" supabase queries #787
andregoldstein
started this conversation in
General
Replies: 2 comments 12 replies
-
Hey @andregoldstein, Do you mean adding an input to a function? Like the below? let input = 'fat & rat'; // can come from user input
const { data, error } = supabase
.from(table)
.select()
.fts('fat cats ate fat rats', input) |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi @andregoldstein, const a = supabase.from("messages");
if (input < 100) {
a.insert([
{
message: "sdf11",
user_id: "8d0fd2b3-9ca7-4d9e-a95f-9e13dded323e",
channel_id: 2,
},
]);
} else {
a.insert([
{
message: "sdf22",
user_id: "8d0fd2b3-9ca7-4d9e-a95f-9e13dded323e",
channel_id: 2,
},
]);
}
if (limit) {
a.limit(10)
}
// fire off the query
await a; |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there!
Seeing as Supabase API querying is chaining operations eg:
.select().filter()
, what would be the best way of building out a query depending on certain values.For example, if there is a search query value (from an input) add a
filter
.I'm sure I'm missing the easiest/best approach here?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions