GetDutchie / brick

An intuitive way to work with persistent data in Dart

Home Page:https://getdutchie.github.io/brick/#/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: Synchronized app indicator

hortigado opened this issue · comments

Hello, I think that a feature that could be implemented would be to be able to show the user if their information is synchronized or when was the last date that it was synchronized. Regards

Hey @hortigado this is tricky because Brick doesn't synchronize all data at once. It synchronizes on demand. I'd recommend adding an updatedAt property to you Dart model and only assigning it on remote update:

@Rest(fromGenerator: 'DateTime.now()', ignoreTo: true)
final DateTime updatedAt;

If you need to access it for all models, you can write a SQL query to pull only the relevant data out:

AppRepository().get<MyModel>(
  query: Query(
    providerArgs: {
      'limit': 1, 
      'orderBy': 'updatedAt DESC'
    }
  )
)