Тёмный

How Do I Paginate My Data? | Get to know Cloud Firestore #7 

Firebase
Подписаться 384 тыс.
Просмотров 142 тыс.
50% 1

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 145   
@NicoloZanetti
@NicoloZanetti 5 лет назад
Amazing course, good job Todd and Firebase crew! I watched all 7 videos published so far in a single morning and I don't feel lost anymore!
@kingsleyforbes-smith2141
@kingsleyforbes-smith2141 5 лет назад
Brilliant, and answers real questions with real limitations (eg costs) , please keep creating.
@luiswebdev8292
@luiswebdev8292 2 года назад
these videos are really really good and instructional, thanks for them
@Firebase
@Firebase 2 года назад
Thank you for the feedback! We aim to provide quality content 😎
@j.guillaumed-isabelle2237
@j.guillaumed-isabelle2237 5 лет назад
I loved this gummy big bear intro haha
@nawaralsafar508
@nawaralsafar508 5 лет назад
The Firestore videos series is awesome. Its nice to have a cool dude make you laugh while you learn about underlying technology. Great content and very helpful. Keep sharing please :D ;)
@d4lep0ro
@d4lep0ro 3 года назад
Remember that incremental (limit) pagination breaks if you have persistence on, queries might trigger from old cached values. Say you query for 10 elements, you might get 2 element from older cache.
@codeconcept
@codeconcept 5 лет назад
Some people tend to say awesome for just 'ok' stuff. But this playlist is really... awesome :) The content, the presentation, the animations. Everything is top quality. Keep up the good work!
@1002CK
@1002CK 5 лет назад
Another way is order query result by timeStamp descending or ascending, then retrieve document according to document timeStamp
@codesnacksIO
@codesnacksIO 4 года назад
This is a good input. Wonder why Todd didn't add it
@1002CK
@1002CK 5 лет назад
So there is a read charge even clients app cached the same document data
@notfound521
@notfound521 3 года назад
Yeah that seem really confusing, in the third video of the serie they said just the opposite so what's the truth?
@mustafaalnoori5213
@mustafaalnoori5213 3 года назад
I think if you want to make this work you need to read the whole collection with attached listener so when anything changes only the change will count as new read
@JohnDoe-zc4mu
@JohnDoe-zc4mu 5 лет назад
LMAO the gummy bear
@Bigjunior987
@Bigjunior987 5 лет назад
If I increase the limit from 20 to 40 to 60, do I really fetch also the first 20 documents all the time? I thought that the Firestore client SDKs cache these documents and send me those documents only if it's needed. Or is it just that I get billed for those, but Firestore tells the client SDK that it already has the most recent version of the first 20 documents?
@blessing7695
@blessing7695 5 лет назад
Great question
@joereem
@joereem 5 лет назад
This is something i struggle with as there are just hints in the document of how caching works and when you will benefit from it. I can do tests and sometimes I do to try to figure if a query is expensive, but it would be easier to remember if I could get a lesson on it. Please make this a future topic for an episode or add a section devoted to it in the documentation.
@Bigjunior987
@Bigjunior987 5 лет назад
@zztop3000 Yeah I know that Todd says that you are re-requesting the old data, but this confuses me. Why should the documents be fetched again? They are already present in the cache of the app. Or do I just get billed for those documents even though they don't get sent to the client?
@acche-rc
@acche-rc 5 лет назад
Because offline persistent is not enabled by default everywhere
@blizzard182
@blizzard182 4 года назад
@@ToddKerpelmanCorp One follow up question. If with the offset you are basically just querying and charging for every record up to the offset, then what is the point of having that parameter at all? You could just request all the records with limit and that would be the same. I always thought of it like pagination and avoiding requesting and charging money for these records. This is actually a huge thing that should be in the docs.
@chriscurnow143
@chriscurnow143 5 лет назад
Hey Todd, are you available to do the instructional videos for our app🤣? Seriously, another great video. I haven't got up to thinking about pagination yet but I will soon and this explains pretty much everything I need to know.
@MuhammadbinYusrat
@MuhammadbinYusrat 5 лет назад
I don't think Google has ever used Firebase for any of their own project because of how many basic things it seems to lack so casually.
@rubenheymans1988
@rubenheymans1988 5 лет назад
this video is great in explaining the theory behind, but where are the code examples? why is this not in the angularfire docs?
@erickeft
@erickeft 9 месяцев назад
Thanks. Would be great to have a new video focusing more in pagination for realtime cases, like chat apps, for instance. It's kind of complicated to find help online for a consistent way to implement pagination with real-time updates with Firestore
@CoryMcaboy
@CoryMcaboy 5 лет назад
It is great to see a video on pagination best practices. Thank you!
@jamieperkins906
@jamieperkins906 5 лет назад
Thanks for this! I would love a video that suggests a schema for commenting on user's posts. It's a little tricky to set it up so it's safe permission wise, but also logical query-wise.
@learnings2173
@learnings2173 2 года назад
Thanks...very informative
@noamgonen6243
@noamgonen6243 5 лет назад
Thx for the simple show of options and associated tradeoffs . PS - where on Earth did you find such a enormous gummy bear? Must have doubled this episode's production costs...
@BogacGuven
@BogacGuven 5 лет назад
Giant gummy bear analogy: spot on.
@CardinalHijack
@CardinalHijack 5 лет назад
So this means that conventional pagination (which has a nav containing 1 - total page count) is impossible out of the box with Firebase - the only option is to infinitely scroll pagination as described. I cant believe this is no way to do this easily with Firebase. Think ill bite the bullet and move over to AWS
@osmanmusse9432
@osmanmusse9432 2 года назад
Best teacher end of story
@MohitAtray
@MohitAtray 4 года назад
@Todd There is a nice idea for you! What if we can extend range of values to listen to while paginating. For example, I do this query for first 20 docs and listen to it -- [limit: 20]. Then when I reach end while scrolling, I do this another query for next 20 docs [startAfter: , limit: 20]. Now it would be awesome if I could just change the limit of what I was listening to in the 1st batch to 40 or maybe change the "end doc" to listen for changes upto. Not send the request, just change what I am listening to.That way, I will only request for 20 docs (20 reads) in 2nd batch and I would be listening to changes in 1st 40 docs. Problem of realtime updating solved! The problem will also be solved if there is a way to just listen to changes in a range of docs without retrieving (requesting for) the docs in the specified range.
@ebonilha
@ebonilha 4 года назад
This wouldn't work because as he mentioned, the database won't keep the pagination state, so the range [0,40] for a specific query is not something it can do without re-doing the entire query.
@JulienReszka
@JulienReszka 4 года назад
did the api change ? nothing of this works currently
@matthewferguson8904
@matthewferguson8904 4 года назад
Wow sorry guys but this is terrible, we need proper paging...
@giuliofederico7638
@giuliofederico7638 3 года назад
Brilliant as ever
@jonnyp
@jonnyp 5 лет назад
great video - thanks - would be great to see a result count for the query as well, though I understand it's not easy in firestore
@smrtsoftware
@smrtsoftware 4 года назад
This pagination this is really cool, not tedious and very efficient. Nice work Google Firebase Team!
@NanduriBharrath_nb
@NanduriBharrath_nb 5 лет назад
Please make your videos as frequently as possible. It's hard to find good Firestore tutorials or courses online.
@NanduriBharrath_nb
@NanduriBharrath_nb 5 лет назад
@@ToddKerpelmanCorp Thanks for writing back!! You are GOOGLE! There's no such thing for you guys that's tough. If you put your will to it.. I guess you'll get it done. Try using softwares like Video Scribe. They are fast and easy to make yet crisp and useful for educational purposes.
@kenechukwuAkubue
@kenechukwuAkubue 4 месяца назад
for the 3rd option, why not check for changes before pulling everything. if there are no updates on the old data its should just pull the new one and merge it with the one it has locally on cache
@pandarzzz
@pandarzzz 5 лет назад
Thank you for sharing this informative video! I hope you are well: Todd & Firebase Team!
@videoguy640
@videoguy640 5 лет назад
Great outro lol. Any way to order by random order while using pagination? Say if I want to give my user 20 random reviews in each batch?
@videoguy640
@videoguy640 5 лет назад
@@ToddKerpelmanCorp Gotcha, I think I'll end up using a cloud function to periodically update the random fields. Not a perfect solution, but cheaper than other options that I can think of
@yeilmusic
@yeilmusic 3 года назад
How to count documents without being charged
@juliangzr4998
@juliangzr4998 3 года назад
you missed one thing, to paginate without infinite scroll we need to know the amount of records the search has, so we can know the amount of pages, how we can do that?
@helmchen1239
@helmchen1239 3 года назад
use a proper database ;)
@nivaldolemos5280
@nivaldolemos5280 2 года назад
Firestore is crap, specially the web SDK. Any supposed gain in productivity vanishes when you reach such simple and common use case. In a SQL database, it's terribly simple.
@thedevguild7525
@thedevguild7525 2 года назад
I believe the key essence here is, the option you choose is dependent on how real-timeliness you want your app to be!!
@raghav4296
@raghav4296 5 лет назад
Hi Todd, was expecting your video after the GA on the enhancements to Firestore and things to lookout for. Any videos in the making? 🎬
@ynonrahamim
@ynonrahamim Год назад
Great explanation! Thanks
@RikHaanen
@RikHaanen 5 месяцев назад
Thanks, I really like your videos. Very clear. One question though: let’s say i page in 20 documents per page and i decide to get the top 60 documents at my 3rd page request. That means the first 40 documents are probably in my local cach alrery ?righ?. If that is the case, the server would only sent me the last missing 20 and not bill me for the 40 that i already have. Is thatvright? And would the system do that automatically our do i need to configure this local cach somehow? Thank, Rik
@Za-rk8gk
@Za-rk8gk 3 года назад
This will be a big issue for most of the companies using Firestore, I was NOT expecting this.
@lazarkatanic4826
@lazarkatanic4826 3 года назад
how?
@nivaldolemos5280
@nivaldolemos5280 2 года назад
Most enterprise apps will need a numeric pagination somewhere, something that Firebase cannot offer. You can only travel to the previous or next page.
@akpokemon
@akpokemon Год назад
@@nivaldolemos5280 I cannot believe this isn't a capability. Oh my god. What the h*ll... I might need to migrate to a completely new database platform...
@rammalvarez2664
@rammalvarez2664 5 лет назад
Really nice, super useful!
@ProfessionalTycoons
@ProfessionalTycoons 3 года назад
super cool and useful!
@vitako7714
@vitako7714 5 лет назад
great video; 2:31; does firestore support query on one field and order by another field now? just wondering if it now supports this what I love to hear or is it just a makeup example to simplify the video? thanks #askfirebase
@sherriecao3491
@sherriecao3491 3 года назад
Brain: you are supposed to keep watching this tutorial Me: I WANT THIS GIANT GUMMY BEAR
@lightlysaltedcalmingvlogsa7286
@lightlysaltedcalmingvlogsa7286 3 года назад
Same
@27sosite73
@27sosite73 2 года назад
nice
@escoladejesusnafreguesiado3319
@escoladejesusnafreguesiado3319 2 года назад
Very nice. But how about jump pagination, imagine i'm on page 3, and want to go to page 7, how do i implement that? there is a function to "jump x docs"?
@satyamgaba
@satyamgaba Год назад
Any updates? I am wondering the same thing?
@everu1450
@everu1450 5 лет назад
When are we getting that video on cloud functions that was promised in #5...?
@sahilkarni1550
@sahilkarni1550 Год назад
what if i use streams and streambuilder and list.view builder, do i still need to paginate ?
@sveinsoermo9883
@sveinsoermo9883 5 лет назад
Would U recommend to combine aggregation with limit, or go with one or the other?
@snj2102
@snj2102 4 года назад
Great video!!! thanks
@dearlordylord
@dearlordylord 2 года назад
Where can I get an edible bear like in the video?
@nickjunes
@nickjunes 3 года назад
Where doesn't seem to work with pagination. Is there a way to combine a where clause and pagination?
@JancoBH
@JancoBH 5 лет назад
Nice video but what about a pagination for webs likes many blogs have with the next and previous pagination?
@Kinthalis
@Kinthalis 5 лет назад
You can cache previous results in your store or what have you. But yeah, if there's a possibility that the user can request say page 20 right off the bat, like say in a forum board app, you'd probably have to work around this. Maybe adding an index to the document so that you can specifically query for document with index > 20 for example.
@skott1e
@skott1e 5 лет назад
This would be expensive because the offset query for 20 records (limit: 20 offset: 40) that you would need for true oldschool pagination would cost 60 reads. Wait, let's say you have 5 pages with 10 records each. In your first query, you must retrieve all first and last records of each page. Then you can navigate with 'start before' and 'start after'. Hmm..
@narongchaijaroonpipatkul5294
@narongchaijaroonpipatkul5294 3 года назад
I have a question. If my documents update index real time, What happen if I separate my collection to 2 collections ? First collection keep data and second keep only index but same key. Then I query first 500 keys from second collection and keep in array call "keys_array". Then I query data from first collection that same key in array 1 by 1 every 20 time when user scroll to the bottom of page. So I can manage pagination by myself and documents will not swap order in user's screen. And if this work, it can make numerical paginations. Because only index that's a number is more low cost than full data of document.
@pongstr
@pongstr 5 лет назад
after watching this, im just not sure wether to paginate at all.. if you orderBy: date will it still return weird order? can you at least show some best practice code examples?
@madanhegde4153
@madanhegde4153 5 лет назад
No! You can go ahead with this: 5:00
@sombriks
@sombriks Год назад
hmm, use start instead offset. got it
@ConstantinChirila
@ConstantinChirila 4 года назад
This tutorial is misleading. There is no pagination. As after wasting half a day, there is still a very hard thing to do to just get the items with index 20 to 40 as they are in a document.
@lukecross5439
@lukecross5439 4 года назад
Well, if the reads from database is scalling to the loaded documents+new documents instead of just new documents (already loaded documents not need load again) then is lower than the original recyclerView and RecyclerView FirebaseUI... this is very bad idea (you will lost realtime updates and your reads from database increases exponentially) .-.
@jeancarloflorescarrasco412
@jeancarloflorescarrasco412 4 года назад
Hi, I have a problem with limit, It always bring 20(for example), when only it is supposed to bring 10 elements. Yes ther another 10 are duplicateds
@_sevelin
@_sevelin 4 года назад
RU-vid team: What is the budget of RU-vid video? Google: RU-vid team: Lets buy a giant gummy bear. That's how it was done
@jonasdo7805
@jonasdo7805 3 года назад
why does everything feel like a one big hack with Cloud Firestore?
@nivaldolemos5280
@nivaldolemos5280 2 года назад
Because it is. But, well, "it scales".
@turskyi
@turskyi 3 года назад
whereEqualTo cannot be used with orderBy!! this video has mistake at [7.57]
@raismohamad2611
@raismohamad2611 4 года назад
How do we know how many pages have using this method?
@zakariachahboun
@zakariachahboun 4 года назад
Thanks man!
@whereismymind6696
@whereismymind6696 5 лет назад
What about scrolling back up?
@robertvos9044
@robertvos9044 5 лет назад
Could RxFire stream handling paginate?
@alejandrorisco4201
@alejandrorisco4201 4 года назад
Imagine that gummy bear made out of rum
@Rajukumar-nl2ok
@Rajukumar-nl2ok 4 года назад
How can we achieve the pagination in PHP language.
@adiemar3974
@adiemar3974 2 года назад
i just hope that firebase would find a solution for better pagination and dynamic queries, but as of now it's not one of the best for obvious reason.
@deepseadiver971
@deepseadiver971 2 года назад
A downloadable Xcode sample project would have been nice.. You spoke on how to use it BUT didn't show the specifics concerning snapshot/listener code implementation... Disappointed.
@jonathangamble
@jonathangamble 4 года назад
Bring 'offset' to the front end!!!
@ThatGuyAnonymous
@ThatGuyAnonymous 4 года назад
offset works, except you, are charged for the docs you skipped. limit(5).offset(10) counts as 15 reads. once again the genius of firebase at work!
@ebonilha
@ebonilha 4 года назад
offset is bad for security. Giving your users the power to read a million documents with a slim query is a leverage point for attacks. And this has nothing to do with Firebase. Limit/skip pagination for arbitrary queries must read all previous documents, and cursor-based ones don't. The only thing is that if you manage your own database this isn't a billing problem, but Firestore is billed per-read.
@sebasmite
@sebasmite 3 года назад
Amazing
@JeffLewis7
@JeffLewis7 5 лет назад
1:40 Infinite Scroll with React Native and Cloud Firestore. How do I this?
@lukecross5439
@lukecross5439 4 года назад
Yes
@SizzlingSquiggle
@SizzlingSquiggle 4 года назад
@@fueledbycoffee583 This gets tricker when you want it in realtime
@ramunas_
@ramunas_ 4 года назад
How to know that it was the last document in the pagination fetch? Lets say I have 100 items and limiting by 20.
@ramunas_
@ramunas_ 4 года назад
@@ToddKerpelmanCorp Thanks!
@ecptavares
@ecptavares 3 года назад
Hi! I have approximately 4.000 records on my firestore and I am paginating it by 20.But what if I am at the beginning and I want to search for an item that hasn't been loaded yet?How would I handle this situation?Thank you!
@mustafaalnoori5213
@mustafaalnoori5213 3 года назад
Query for it !
@juanalvarenga3393
@juanalvarenga3393 4 года назад
How could I implement this idea in a chat according to what it mentions from the minute: 6:40, I am working in a chat and it is ready, but if I limit the number of messages in the first load and through a scroll I want to access data Previous, I miss the realtime, if someone has a very helpful example, thank you.
@mustafaalnoori5213
@mustafaalnoori5213 3 года назад
Same idea but the query must be for ascending timestampe
@karthiksenthil1085
@karthiksenthil1085 5 лет назад
how do phone otp authentication using react native and firebase please tell me
@collinslagat3458
@collinslagat3458 5 лет назад
Brilliant
@sture1985
@sture1985 5 лет назад
#askfirebase Does the Firestore SDK support something like SELECT * from documents ORDER BY random() LIMIT 1?
@MyAsdfqwe
@MyAsdfqwe 5 лет назад
it does, but by using bunch of functions provided in the api.
@maxosall6972
@maxosall6972 5 лет назад
Awesome
@ben34256
@ben34256 5 лет назад
Is there a security rule to limit the amount retrieved?
@amitk.512
@amitk.512 5 лет назад
Yes we can limit it in security rules
@joereem
@joereem 5 лет назад
An earlier video in this series explains how security rules cannot be used to limit the amount retrieved. If they are in place and a query is made that would be limited by a security rule, the query will fail.
@hieunguyenzzz
@hieunguyenzzz 5 лет назад
so you are charging on every single document read, that's so bad when I just want to have a total number of my documents and you charge me like I am doing 1000 read just because I have 1000 documents
@noumanhanif1948
@noumanhanif1948 5 лет назад
keep a counter that you increment decrement on every document add/delete respectively. Then you will have the count in one read and you can do as many as you want
@akpokemon
@akpokemon Год назад
@@noumanhanif1948 that doesn't account for any filters that your user applies in a search/filter bar
@xainard1114
@xainard1114 5 лет назад
#askfirebase How to count without getting all document?
@Bigjunior987
@Bigjunior987 5 лет назад
You can build a Cloud Function which cleverly counts the number of documents and saves it somewhere in the database. Keep in mind to deduplicate possible duplicate function executions.
@alexr.4409
@alexr.4409 5 лет назад
not possible
@shaikhsaiofali8432
@shaikhsaiofali8432 5 лет назад
How can we implement this on stream builder?
@d-apps2699
@d-apps2699 4 года назад
I tried this with streambuilder and I don't recommend, If you just can load the documents, add in a list and show, It's better, that's how I doing on my app and it's working fine.
@diogogaio
@diogogaio 4 месяца назад
lots of limitations...., poor methods, video is old....
@lucaban
@lucaban 4 года назад
What is `whereField()` ? :D why not just `where()` ?
@itssidhere
@itssidhere 5 лет назад
How to get the last 50 docs ?
@ebonilha
@ebonilha 4 года назад
Just reverse the sort. Switch ascending with descending or vice-versa
@Pizzaguy2
@Pizzaguy2 2 года назад
I still dont know how to do it , I only learned how not to do it
@Klazyo
@Klazyo 4 года назад
I don't have Money
@rickloyd8208
@rickloyd8208 5 лет назад
Awesome but I would prefer either limit star, end or after row_id. That way I can see from code what's going on and save on execution of extra code. May be I am too old fashioned :) Awesome, I had no clue that offset would charge me for all reads I am not actually getting. Another warning that developer should read documentation to get the best results for lowest price :)
@user-ql5to3rh1o
@user-ql5to3rh1o 5 лет назад
i want that gummy bear
@benton202
@benton202 4 года назад
this is the most confusing function of firestore .....
@zorloth
@zorloth 5 лет назад
wow, startAfter instead of offset. Bet loads of people are using offset and wasting $$.
@lukecross5439
@lukecross5439 4 года назад
FirebaseUI Pagination not can capturate the Snapshot Document
@jorgemoraleslopez5575
@jorgemoraleslopez5575 5 лет назад
This video has opened the way for me, I am doing geospatial queries with geofirex, github.com/codediodeio/geofirex, but it is not possible to page and at the moment it does not have a limit method, I could see in its explanation that the way, although it is expensive would be to increase the limit in each query ... This library does have the ability to limit queries https: //github.com/geofirestore/geofirestore-js ... There is a better alternative for geospatial queries for javascript?
@John-doe793
@John-doe793 4 года назад
broo I spent a lot of time "paginating" as documentation says then I realised that I can use 'offset'... dammit
@sudomakes
@sudomakes 4 года назад
Maybe you didn't listen till the end... You get billed even for the documents you are supposed to offset by, which defeats the purpose
@varunmanjunath9123
@varunmanjunath9123 3 года назад
@@sudomakes ikr, hope that guy read your comment, or his firebase app will give him A BIG CHONKY bill of 500$ one day... xD
@tntg5
@tntg5 2 года назад
Please add getLength() method to collections. Otherwise, pagination feels like walking down stairs blindfolded
Далее
100 Firebase Tips, Tricks, and Screw-ups
24:31
Просмотров 188 тыс.
Model Relational Data in Firestore NoSQL
9:13
Просмотров 376 тыс.
Firestore Security Rules - How to Hack a Firebase App
10:05
Firestore Data Modeling - Five Cool Techniques
11:44
Просмотров 256 тыс.