2

I am learning Sitecore and I would like to know best practices on where should I store user specific data

For example: I am implementing "TODO List" website.

Where should I store "Task" models? Should I store them in database and access them through ORM (EF, etc.) or I should create new "Task" items in Sitecore?

Thanks!

  • Does those TODO List be managed via Sitecore? I mean, updating text etc – Hishaam Namooya Apr 3 at 7:04
  • @HishaamNamooya I would like to provide ability for users to manage TODOs out of Sitecore Client. – Sitecore Minsk Apr 3 at 7:10
  • Then there is no need to have those items set in Sitecore. You can create a custom database and store / retrieve them using EF. It will be much easier than storing it in Sitecore – Hishaam Namooya Apr 3 at 7:13
  • @HishaamNamooya are there any ability to save and retrieve data throw custom database and also use this data in sitecore? For example, make users to save and read data throw custom client AND also retrieve this data to display on carousel managed by Sitecore? Thanks – Sitecore Minsk Apr 3 at 7:20
  • By displaying the data on a carousel and managed by Sitecore, you want the content to be editable in Sitecore? – Hishaam Namooya Apr 3 at 7:35
2

Since the data is user-specific, for your TODO-list example storing it in Sitecore items does not make sense and does not add value. It is important to have a clear separation between your business domain data (TODO items management) and content (localizable data you store in Sitecore).

There are several approaches for such cases:

  1. Your Sitecore renderings can retrieve data from your custom database (of course it is advisable to abstract the storage via Repository/Service patterns, which you can inject into your rendering code), combine it with Sitecore content (if needed, e.g if your TODO items have some localizable content, like labels) and render it all together.

  2. Alternatively, you can also build a Web API which will be responsible for providing data for your renderings. In this scenario, your frontend code will be responsible for calling this API. This ensures even higher degree of separation of your business domain data and Sitecore content. This can also lead to a broader discussion on where to store/host the business logic in your Sitecore projects, which is covered in this question: Sitecore helix pattern and where to place your business logic

Note: When building such kind of components which combine external data and Sitecore items it is also important to consider Experience Editor support. For example, you have to make sure that in Experience Editor mode you don't query data from your 3-rd party system, but you provide some mock data instead (because there is no authenticated user context and your Content Editors do not care about the data itself, they only care about content).

  • Thank you! This is exactly what I was looking for – Sitecore Minsk Apr 3 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.