postgresqlpostgrest

Postgrest query. Select * from table when id = id or (user id = id and boolean = true)


Im trying to do what a simple query in postgres on postgrest.

Basically this is the query I am trying to recreate (ID, Other_id and boolean are all columns in the table)

SELECT * 
FROM TABLE 
WHERE ID = 'ID' 
   OR (OTHER_ID = 'OTHER_ID' AND BOOLEAN = true);

I have tried the postgrest url below (following the docs)

https://table?and=(id.eq.id,or(boolean.is.true,other_id.eq.other_id)) but it isn't working.

Any help appreciated.


Solution

  • seems like you need to pass it like this :

    https://table?or=(id.eq.id,and=(boolean.is.true,other_id.eq.other_id))
    

    based on documentations , the syntax is like opertaor=(operand1 , operand2) , so basically you are doing "or" first because this is what you are doing

    OR=(x,Y) but then Y is a mixed criteria so OR=(x,AND=(a,b))

    hopefully that clears up.