Preferred way to handle database records involving 2 users?

Hi,

I’m wondering what the preferred way is to display records in the database that were created by one user, for another user. In my case, transactions.

User A creates a bill for user B.

This makes a new record in my “transactions” database table in Bubble. In each transaction “thing” I have the email address of User A AND User B.

I want to be able to display all transactions that have been assigned to user B (have user B’s email in them). I want to display several fields from the table. Ie: transaction date, amount, etc.

It looks like I can “do a search for” every single item I want to display (wasteful).

Is there a way to return a handle to the item in the database so it can return the whole record in one search and I can just display the fields I want to from the record that is returned?

Thank you!

Am really sorry I didn’t get what you meant clearly please,

I’m sorry. I’ll try again using more Bubble terminology than regular database terminology.

I have a list of “things” called Users. I also have a list of “things” called Transactions.

Users:
UserA, john@user.com, creation date 12/22/22
UserB, jane@otheruser.com, creation date 11/22/22
UserC, Cuser@adifferentemail.com, creation date 1/2/23

UserA (john) can charge UserB (jane) by creating a bill. Each bill is stored in a list of things called Transactions. UserC can also charge Jane by creating a new transaction for her to pay.

Transactions:
3/21/23, $300.00, jane@otheruser.com, john@user.com
3/20/23 $400.00, jane@otheruser.com, cuser@adifferentemail.com

I want to create a repeating group of things to display ALL of Jane’s transactions she needs to pay with the following fields:

Transaction date, Amount, Person who billed her:
3/21/23, $300.00, john@user.com
3/20/23 $400.00, cuser@adifferentemail.com

The above in bold is what I want the repeating group to look like.

What is the most efficient way to “do a search for” on the transactions so that only Jane’s transactions are returned and display the fields I want to display like above?

When I created a repeating group in the past, I make a “do a search” for each field.

Is there a way to just return the entire transaction and display the data from the transaction that was returned without having to do a search for every little field I want to display?

IMPORTANT: The logged in user (Jane) is not the creator of the transaction.

Because Jane did not create the transaction thing, I have to “do a search for” rather than “current user’s thing”. Like this.

Is it efficient to “do a search” for each individual item like transaction date, amount, etc, etc, etc?

Or is there a more efficient way to get the entire “thing” at once with one “do a search for” and display the fields I want from it (like amount, date, etc etc)?

You shouldn’t be doing a search for each field (and you won’t be anyway, even if you think you are)…

Just search for the transactions for the relevant User (although if your privacy rules are set up correctly, only the relevant transactions will be avalable anyway). Then display whatever data you want.

1 Like

Okay I get it now,

Firstly what I will suggest you should do I’d that you should have another datatype for transactions in the transaction data type you will add a field like (owner) the field owner will be type user, that will speak to the person that owns the transaction so after that add the expected field you need. So anytime user want to make transaction for example.
John@user.com want to create a transaction for cuser@adifferentemail.com so the workflow will be created new transaction and the owner filed will contain current cell user (cuser@adifferentemail.com) then you add the other expected field.

Now to query your repeating group to display the bills for the current users, it will be

Do a search for transactions then add a constraint then add the owner field you can use either “=” or “contain” current user.

And if it that you want to display the transaction that was created by the current user it will be

Do a search for transactions then add a constraint then add the creator field you can use either “=” or “contain” current user.

I think this would help solve this problem.
If you need more explanation you can reach out to me faidurrahmaan@gmail.com.