---
# System prepended metadata

title: Updated and tested APIs

---

# Updated and tested APIs
### Updated SQL query
```sql=
export const getAllDonationSql = `
SELECT 
     donation_items.donation_id,
    user_profiles.uid AS creator_uid,
    user_profiles.first_name || ' ' || user_profiles.last_name AS creator_name,
    title,
    donation_items.description,
    target_nominal,
    total_earned,
    img_url,
    donation_items.status
FROM
    donation_items
INNER JOIN user_profiles ON donation_items.uid = user_profiles.uid
INNER JOIN 
    (SELECT transactions.donation_id, SUM(nominal) as total_earned 
    FROM transactions GROUP BY transactions.donation_id) as sub_query 
ON donation_items.donation_id = sub_query.donation_id
WHERE status = $1
LIMIT $2
OFFSET $3
`;

export const getDonationByIdSql = `
SELECT 
    donation_items.donation_id,
    user_profiles.uid AS creator_uid,
    user_profiles.first_name || ' ' || user_profiles.last_name AS creator_name,
    title,
    donation_items.description,
    target_nominal,
    total_earned,
    img_url,
    donation_items.status
FROM
    donation_items
INNER JOIN user_profiles ON donation_items.uid = user_profiles.uid
INNER JOIN 
    (SELECT transactions.donation_id, SUM(nominal) as total_earned 
    FROM transactions GROUP BY transactions.donation_id) as sub_query 
ON donation_items.donation_id = sub_query.donation_id
WHERE donation_items.donation_id =$1
`;

```

### Test
![](https://i.imgur.com/j0n44Gz.png)
