Tuesday, March 17, 2026
HomeiOS Developmentios - Many to Many Relationship in Supabase for Swift

ios – Many to Many Relationship in Supabase for Swift


How can I choose all bills and in addition their tags. I’ve expense desk and tags desk after which the expenses_tags desk.

In Swift I’ve the next:

struct Expense: Codable, Identifiable {
    var id: Int?
    let identify: String
    let quantity: Double 
    let budgetId: Int
    var receiptPath: String?
    var tags: [Tag] = [] 
    
    personal enum CodingKeys: String, CodingKey {
        case id = "id"
        case identify = "identify"
        case quantity = "quantity"
        case budgetId = "budget_id"
        case receiptPath = "receipt_path"
    }
}


struct Tag: Codable, Identifiable, Hashable {
    var id: Int?
    var identify: String
}

At the moment, once I fetch bills I exploit the next command.

let bills: [Expense] = strive await supabaseClient
                    .from("bills")
                    .choose()
                    .eq("budget_id", worth: budgetId)
                    .execute()
                    .worth

I attempted the next:

 let bills: [Expense] = strive await supabaseClient
                    .from("bills")
                    .choose("id, identify, quantity, budget_id, receipt_path, tags(id, identify)")
                    .eq("budget_id", worth: budgetId)
                    .execute()
                    .worth

Nevertheless it retains throwing exceptions.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments