How do I know which item is not synced - aws-amplify

I'm using AWS Amplify DataStore to store data to the cloud. When the device is offline, DataStore will keep the data in local storage until it's online again.
This is working fine but I'd like to display an offline/to be synced icon next to the those items that are not pushed to the cloud yet.
DataStore.query only seems to give me the content based on the model defined, is there any metadata I can use to determine whether or not an item is saved to the cloud?
Thanks!

Related

Find n nearest locations in flutter: local database (Sqlite) in combination with Cloud Firestore vs Firebase Realtime Database

I am working on the following topic right now:
about 8000 stores/objects(uniqueID, name, adress, latitude, longitude, geohash, amount of productX, amount of productY.)
in the future there will be new stores and also some of the stores will be deleted
I am planning to add a version attribute to each data: for example I start with version1. If I receive an update or a new store then it will have version2
it is not needed to receive realtime changes. This data will be changed only a couple of times each month
Flutter app with a feature: find n stores at this location
because the data is not changed frequently I was planning to put an updated local sqlite database to each build
I will use Realtime Database or Firestore to receive updated data within my app to avoid to publish a new version only because database was changed
Firestore: I will add only a new attribute to my document and I will request all data that is newer than my local database version and I will also have a collection that has all deleted items
Realtime database: here I would have something like this
-updates
version1
newData: List of unique IDs
deletedData: List of unique IDs
I read a lot about geo queries on firestore and I also found a working flutter plugin to do this filtering on serverside, but because my data is not changed that frequently I am very confused about the best approach.
Questions:
Is my approach a good idea or should I forget about the local sqlite DB and use only Firebase/Firestore?
If I will use the local database and will only observe updates from the backend, which of the services should I use in terms of pricing etc.? (Advantage Firestore: If I use Firestore I can easily switch to it by using the flutter plugin and forget about my local database)
If you have only a couple of thousand objects, and the data hardly every changes, I'd typically consider querying the data locally on the device. You can likely very quickly iterate over the 8,000 items to check their lat/lon against the user location.
You could then use something like Firebase Storage or even Firebase Hosting to distribute updated data sets to the users. Of course you could use Firestore or Realtime Database for that too, but if you're not using their querying or realtime capabilities, there are cheaper options to distribute a static file.

Viewing database in Firebase Console

So this morning I woke up to a minor Firebase Console design. The left side menu usually has
Authentication
Database
Functions
I don't remember the fourth item
But today there is Realtime Database and a couple of added items see attached image. When I click Realtime Database I can not see my existing database but instead see a CTA to create a database and some documentation links.
I am using the following link to access the console https://console.firebase.google.com/u/0/project/my-project-name
How can I can access my database?
From the tag used in your question I understand that you are using Cloud Firestore (and not the Realtime Database).
Firebase offers two cloud-based database services, which both support realtime data syncing: Cloud Firestore and the Realtime Database (the Firebase's original database)
Before yesterday (12 August 2020), on the Firebase console, there was only one vertical menu item for these two database Services.
Yesterday, this unique vertical menu item for Database Services was splitted in two: one vertical menu item for Firestore and one for the Realtime Database.
The URLs for each database "console page" have therefore changed. To access your Firestore database console you should select the "Cloud Firestore" vertical menu item.

Firebase database and google cloud storage out of sync

I can upload a new object to the google storage bucket, and it will put the object in the database for the firebase project. But when I delete it does not update the google storage bucket -- any tips for how to get to the bottom of this?
Additionally there are a couple thousand objects in the google storage but not in the firebase database. How do I sync these two so the objects in the GS bucket are also in the firebase database
I tried a test and using gutils rsync uploaded an image, then deleted it in the firestore and when i tried uploading it again I get
Building synchronization state...
At destination listing 10000...
At destination listing 20000...
At destination listing 30000...
At destination listing 40000...
Starting synchronization...
Copying file://./.DS_Store [Content-Type=application/octet-stream]...
- [1/1 files][ 6.0 KiB/ 6.0 KiB] 100% Done
UPDATE:
I believe it has to do with an issue with 'application/octet-stream' vs image/jpeg and deletions -- any advice for how to switch those over to image/jpeg
You can write two Cloud Functions triggers, one that responds to changes in your storage bucket (a storage trigger), and another the responds to changes in your database (a Firestore trigger). If either function detects a change, it can make a corresponding update in the other product.
If you want to perform a one-time synchronization, you will just have to write code to find the differences and make the appropriate changes. A Cloud Functions trigger would not be the best way to do this.

Control when Firebase Database syncs data

I'm thinking moving an Android app's persistent data to Firebase Database. Currently I use Sqlite with a Python HTTP REST service.
In the app, I have a big list of cities, called citiesList. Since the list is quite big and hardly updated, I don't want the app fetch the list whenever it goes online.
My current strategy is provide a citiesListVersion. When the app goes online, it checks citiesListVersion. If the server's citiesListVersion is newer, the app will fetch citiesList from server. Otherwise, the app continues working with the cached data.
My question is: can I keep my current strategy when moving to Firebase Database? As I understand, Firebase tries to sync data whenever the app goes online.

How optimize Firebase database size

I'm new with Firebase technology and I would like to optimize Firebase database size (including for decrease cost).
What are the different ways to decrease Firebase database size?
Can I simply use node names as short as possible, for example instead of having a node "user", rename this node "u"? (relevant if this node is very present)
Do there are other tips?
Here's the approach we take from one of our mobile apps:
We have a mobile app, web service, Firebase Database and Firebase Storage. We sometimes have a small SQL database as well.
We have the mobile app display data from Firebase but write data to Firebase via the web service, never directly.
We started with using Firebase Database as our storage, then changed to a hybrid Firebase Database + Firebase Storage mix.
We now store the "view data" is Firebase Storage and only store a "stub/pointer" in the Firebase Database (it reduces data size and it reduces traffic).
We end doing an extra read from Firebase Storage every time the value of a "stub/pointer" changes in Firebase Database, but that works for our scenario. We also don't do it for every situation, so we peek and chose where it makes sense to use this approach.
We ended up reducing cost - that was our main reason to search for a solution and it looks like that's your motivation as well.
Other than that, using short names for the key names may help as well.

Resources