Don't want to replicate the complete data in the Mobile local storage

Hi everyone,

I want to fetch only limited records from the server database into my mobile storage database, is it possible?  As far as I understood the whole local storage is replicated for an entity under the data tab in a module then we can filter the data once we use them on our screens as aggregates. But my data is very huge I don't want it to completely replicate to my phone storage, is it possible?


Thank & Regards,

Shivya Pant

Hi,

You have full control of how your data gets migrated from the server to the mobile application. There are several different ways to sync the data.

  • You can do a full copy
  • Just a copy of part of the database
  • Have different data models on the server and on the app
  • Sync on log in
  • Sync only what is necessary when necessary
  • etc

For more information: https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Offline

I hope it helped,
Pedro Almeida

Hi Shivya,

You are in full control to what extend you synchronize from the server to the local database of your application.

Some examples

  • Given a todo application, which are stored for all users on the server, only the todo items of the the logged in user need to be sync't with the local database on the phone, not those of all users.
  • Entity on your server has 40 attributes, on your mobile you only need 15.
  • On server you have 4 related entities, but you can simplify your local database model to less entities and make the sync and your mobile app more performant.

It is actually a mobile best practise to NOT replicate the server database to your mobile.

For more information see OutSystems Mobile Best Practices section Design a Lightweight Local Storage,

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Shivya,

You are in full control to what extend you synchronize from the server to the local database of your application.

Some examples

  • Given a todo application, which are stored for all users on the server, only the todo items of the the logged in user need to be sync't with the local database on the phone, not those of all users.
  • Entity on your server has 40 attributes, on your mobile you only need 15.
  • On server you have 4 related entities, but you can simplify your local database model to less entities and make the sync and your mobile app more performant.

It is actually a mobile best practise to NOT replicate the server database to your mobile.

For more information see OutSystems Mobile Best Practices section Design a Lightweight Local Storage,

Regards,

Daniel


Hi Daniel,

Thank you for your response. Actually I want something like the first bullet point, I just want to retrieve the data of the user wo is currently logged in like on the basis of userID.  Yes in the ToDo App we did that but nowhere I put the filter for the UserId to fetch the ToDos for the logged in user.


Thanks & Regards

Shivya Pant

Solution

Hi Shivya Pant,

After login on mobile app, you get a valid user identifier using GetUserId().

To save the data locally you need to fetch the data you want using an aggregate or SQL query and filter the data the way you want. After that step you can create the records locally and use it.


Cheers,
Emanuel

Solution

Hi Shivya,

As Emanuel already mentioned, you can only filter your server data for your local user by using the GetUserId() and having a foreign key to the User entity in the table that you query. This also applies to the Todo example mobile application. 

For more information about syncing you can read Implementing offline sync and Offline Data Sync Patterns

Regards,

Daniel