Default inputs for an Empty items in the database collection

hello,
i am building a user profile page for my members on my wix site. I am using dynamic page for the profile that reads from a data collection in the database generated by the users themselves.
my question is:
when a user DONT fill some data (for example profile picture), the database item is empty and the dynamic page show nothing. I need to make the dynamic page show default item (for example default profile picture) when the user don’t submit any.

any idea how this can be done?

There are 2 ways of doing that: At writing time or at reading time.

  1. Writing time : use a beforeUpdate/beforeInsert hook to set default value for missing property.

  2. Reading time: once the dataset is loaded, set a default value for the property without value.

Option 1 one required less work overall but option 2 is better because the collection will not hold virtual pre-made values (user might update the value later and does not want to have the field pre-filled with a default value).

Hi Kentin,

I stumbled across your reply. I’m currently facing the same issue.

New User here. Could you kindly help with the code for Option 2?

Thank you

I am also interested in know how to setup Option 2. How do you set a default value for a property without a value?