# Save/restore component properties to DB

**URL:** <https://forum.inductiveautomation.com/t/save-restore-component-properties-to-db/88383>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 4, 2024, 10:07pm UTC](https://forum.inductiveautomation.com/t/save-restore-component-properties-to-db/88383 "2024-04-04T22:07:48Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [April 8, 2024, 10:13pm UTC](https://forum.inductiveautomation.com/t/save-restore-component-properties-to-db/88383/9 "2024-04-08T22:13:23Z")

</div>

> [@David\_Nicks](#):
>
> user preferences sticky during a session, but then they'd lose them on a new session - correct?

Correct. To make it sticky, save/load from the DB.

> [@David\_Nicks](#):
>
> Maybe it's easier to save & restore the session custom properties to a DB than each of the table properties?

I'd say this is much easier and more transparent than diving into using SDK functions, especially if you get another engineer who knows nothing about the project/customization data. (That's my opinion anyways). It would also essentially 'live' in only one or two places, the session startup handler and the user id value change event, as opposed to every component that needed some sort of customization.

You could have a structure something along the lines of:

```auto
personalization
├ Tables
│ ├ TableTypeA
│ │ ├ Columns
│ │ ├ Filters
│ │ └ Rows
│ └ TableTypeB
│ └ Columns
├ Graphs
│ ├ GraphTypeA
│ └ GraphTypeB
└ ETC...

```

All your script would need to do is poll the DB for the provided user and transform the data into the correct structure and place that structure into the session property. Simple 3 line script for the event.

```auto
	databasePersonalizationData = system.db.runNamedQuery("GetPersonalization", {"OperatorId": operatorId})
	personalizationObject = personalizationDataToObject(databasePersonalizationData)
	session.custom.personalization = personalizationObject

```

with `personalizationDataToObject` doing all the structure transformation.

---

_[View the full topic](https://forum.inductiveautomation.com/t/save-restore-component-properties-to-db/88383)._
