What would be the best way to manage user settings?
For example, i want to allow users to customise their dashboard, hide specific orders from their shop and so on.
What i think of is , to make lots of fields under user type, on/off. For example hide_canceled_order - yes/no
Alternatively you could create a new type called Usersettings to hold all the information. And then just add one field on the User type. I guess that would make the User more clean and I can’t see any downside to that.
The thing is that, if i take the second aproach, then i need something like this:
Type= settings
settings can have multiple fields like, hide canceled orders, hide that menu and so on.
But when i go to users account page and turn a setting on/off i cannot do it like: Make changes to CurrentUsers Settings - hide canceled orders - yes/no.
I have tried it but it creates a value every time instead i need to do it like this:
Thats what i did. But the issue is that, you always need to work with “First item”. When you create new setting, when you edit that setting and so on. So, you ll always need to : “Do a search for:curentUser setting: first item”
If i do it as you say (the same i thought) then you get multiple entries for user:
I don’t fully understand the problem. Take this as an example - here you don’t do a search, you just access the current user’s settings. But maybe I misunderstood how you wanted to structure the settings data type. If you just continue adding fields for each thing you want to save, I don’t see a need for searching.
The problem is that, if i use “Make changes to settings” for some reason it creates a record every time. It does not make change. You got it? I get a line in database in settings, each time user performs an action. I would like to have only 1 line and keep editing that.
just keep it the same way it is. When the this option is enabled the database will keep updating the same entity. If the values are not the same then it will create it the first time. Don’t store this like this, you can remove that!