User search and value modification - How can I do this?

Let’s say I have 1,000 users registered in the database. Now, I am looking for a way that one user can send another user one or more gifts.

If a user receives a gift, it should be written in a data field that contains the following information:
• when was a gift received (timestamp)
• which user sent a gift (username of the sender)
• how many gifts were sent from the other user (number)

As each user shall be able to send gifts to others, each user should also have a data field that tracks:
• when was a gift sent (timestamp)
• to what user was the gift sent (username of the receiver)
• how many gifts were sent (number)

Each user shall start with 10 gifts. If he sends gifts, the number should be deducted from his gift balance and if he receives gifts, the number shall be added to his gift balance.

There is probably an easy way to achieve this, but I am currently struggling.

Like always, there are a few ways you could go about this…

The simplest way would be to create a single datatype for ‘Gift’, containing all the information you’ve outlined above…

Then you can use the ‘count’ of gifts to set whether a user can still send more gifts or not, and display how many gifts a user has let to send.

Or you might want to use lists fields on the User (or on a separate datatype) to keep track of gifts sent and gifts received (then you can just count those).

You could also break the data up into several datatypes (i.e. ‘Gift’ ‘Gift_Sent’ Gift_Received’ etc) depending on exactly what you need to do.

Thank you very much! I’ll try it.