Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
304 views
in Technique[技术] by (71.8m points)

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:

  1. Is my approach a good idea or should I forget about the local sqlite DB and use only Firebase/Firestore?
  2. 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)
question from:https://stackoverflow.com/questions/65841213/find-n-nearest-locations-in-flutter-local-database-sqlite-in-combination-with

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...