Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do I get collection length? #50

Open
sarwarcse opened this issue Aug 10, 2021 · 3 comments
Open

how do I get collection length? #50

sarwarcse opened this issue Aug 10, 2021 · 3 comments

Comments

@sarwarcse
Copy link

if there is a table named customer.
then how can I get the counter of total customers.

Another scenario is :
if I have multiple status of customer, where active customer is more then 100.
I want to show the counter of total active customer but I will get 10 rows of 100; I want to make a response like this :

 let response ={
      total_rows:100, 
      row_limit:10,
      total_page:10,
      current_page:1, // it means 0 to 10 positions data
      rows:[{1},{},....{10}]
  };
//db.collection('customers').doc({status:"active"});

@teamsuperpanda
Copy link

For the counter I just grab the collection and assign it to a variable.
Using variablename.length you get how many objects (in this case customers) there are.

Localbase is similar to Firebase but I haven't seen in the docs anything about how to handle limiting docs into groups.
You can limit to 50 but it only returns the first 50. I can't help you with fetching 50+ and limiting from there but because it is local you could use vuex or even just a function to return what you need.

@Jargonius
Copy link

I also would like to be able to get count or length much like in SQL. I don't know if it's the same here but I'm SQL is faster to call count than to get all the records and get the length of the result.

@samuk190
Copy link
Owner

I also would like to be able to get count or length much like in SQL. I don't know if it's the same here but I'm SQL is faster to call count than to get all the records and get the length of the result.

It's possible I'll look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants