Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/masaok/supabase-notes
Supabase Notes 2025 (Backend as a Service)
https://github.com/masaok/supabase-notes
baas postgres supabase
Last synced: 3 days ago
JSON representation
Supabase Notes 2025 (Backend as a Service)
- Host: GitHub
- URL: https://github.com/masaok/supabase-notes
- Owner: masaok
- Created: 2024-03-07T03:09:59.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-22T03:16:25.000Z (2 months ago)
- Last Synced: 2024-12-01T22:22:17.131Z (2 months ago)
- Topics: baas, postgres, supabase
- Homepage: https://supabase.com
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Joining a table with multiple foreign keys using `ON` SQL behavior
```typescript
import { createClient } from "@supabase/supabase-js";// Initialize the Supabase client
const supabaseUrl = "YOUR_SUPABASE_URL";
const supabaseKey = "YOUR_SUPABASE_KEY";
const supabase = createClient(supabaseUrl, supabaseKey);async function fetchAttendanceWithScansAndFlatten() {
const { data, error } = await supabase.from("attendance").select(`
*,
scans:scan_id_start!inner (
timestamp
)
`); // Using !inner to ensure we only get records with a matching scanif (error) {
console.error(error);
return;
}// Map the results to include scans.timestamp at the same level as attendance data
const flattenedData = data?.map((item) => ({
...item,
scan_timestamp: item.scans?.timestamp,
scans: undefined, // Optional: remove the scans object if you don't need it anymore
}));return flattenedData;
}// Call the function to fetch and process the data
fetchAttendanceWithScansAndFlatten().then((data) => {
console.log(data);
});
```https://chat.openai.com/share/85cdc4a0-fac6-45c9-a775-3ed14b5116b3