Chanda Musonda
Chanda Musonda

Reputation: 1

Favourite Item: flutter and supabase

I have a tables in my supabase database called properties, profile and saved.

The schema for the tables looks like this:

properties
  id int8 (pk),
  created_at timestamptz,
  description text,
  price text,
  address text,
profiles
  id uuid (pk),
  updated_at timestamptz,
  username text,
  email text,
saved
  id uuid (pk),
  created_at timestamptz,
  userid uuid (fk) references id from profile,
  propertyid int8 fk) references id from properties 

I created a CustomLikeButton in the below like_button.dart

import 'package:flutter/material.dart';

class CustomLikeButton extends StatelessWidget {
  final bool isLiked;
  void Function()? onTap;
  CustomLikeButton({super.key, required this.onTap, required this.isLiked});

  @override 
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Icon(
        isLiked ? Icons.favorite : Icons.favorite_border,
        color: isLiked ? Colors.red : Colors.grey,
      )
    );
  }

}

I'm having trouble creating functions that can query the saved table, insert rows into the query table and also delete rows from the query table whenever a property listing is liked or unliked. Any help especially tried and tested will be helpful

Upvotes: 0

Views: 69

Answers (1)

Supabase Enjoyer
Supabase Enjoyer

Reputation: 370

Have you tried Postgres Functions and RPC?

Upvotes: -1

Related Questions