-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
doclite built in functions #21
Comments
@REDAL in answer to your first question, yes the query builder has a count() method, e.g.
In regards to your second question, you can't use an array as search criteria but you chain conditions on the query builder as much as you like using
Please see the advanced queries section of the documentation |
Hii Dwgebler,
Thank you for your reply,
Yes, I used, those functions, but in the scenario above, where 2 criteria are related, with OR ?
Regards
…________________________________
From: dwgebler ***@***.***>
Sent: Friday, September 2, 2022 12:43:39 AM
To: dwgebler/doclite ***@***.***>
Cc: redaloui ***@***.***>; Mention ***@***.***>
Subject: Re: [dwgebler/doclite] not creating new document (Issue #21)
@REDAL<https://github.com/REDAL> in answer to your first question, yes the query builder has a count() method, e.g.
$numUsers = $users->where('active', '=', true)->count();
In regards to your second question, you can't use an array as search criteria but you chain conditions on the query builder as much as you like using and() and or() functions, e.g.:
$users->where('registered', '=', true)->and('active', '=', false)->fetch();
Please see the advanced queries section of the documentation
https://github.com/dwgebler/doclite#advanced-queries
—
Reply to this email directly, view it on GitHub<#21 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABZR4KFXDEREJTXWJRN6IALV4E5SXANCNFSM6AAAAAAQBZRRZM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@REDAL there is an example in the advanced queries section of the documentation - if I understand correctly what you're trying to do, you want the
The combination of all query functions, |
Thank you very much will try it now 😎🙏
Kindest regards
…________________________________
From: dwgebler ***@***.***>
Sent: Friday, September 2, 2022 12:42:33 PM
To: dwgebler/doclite ***@***.***>
Cc: redaloui ***@***.***>; Mention ***@***.***>
Subject: Re: [dwgebler/doclite] not creating new document (Issue #21)
@REDAL<https://github.com/REDAL> there is an example in the advanced queries section of the documentation - if I understand correctly what you're trying to do, you want the union() and intersect() functions which allow you to group clauses. An example of an efficient count with grouped clauses:
/ / Get the total number of users where (active=true AND email != "") OR (active=false AND email == "")
$numUsers = $users->where('active', '=', true)->and('email, 'NOT EMPTY')->union()->where('active', '=', false)->and('email', 'EMPTY)->count();
union() groups the clauses on either side by OR,intersect() groups the clauses on either side by AND.
The combination of all query functions, where(), and(), or(), union() and intersect() can be chained as much as you like to create whatever query you need.
—
Reply to this email directly, view it on GitHub<#21 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABZR4KBEDXZOXW53QVFP5YLV4HR2TANCNFSM6AAAAAAQBZRRZM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@dwgebler it worked like a charm :) what about getting the last ID? , is there any built-in function , or how you do it regards |
There isn't any concept of a "last ID" in DocLite since the ID can be any unique string value. If you want to know the ID of a newly saved document, you can just call |
Hi Doclite,
thank you for the awesome library,
is there any built-in function for example to get the count of documents in a collection, and such functions? (like the last id)
if not, is there any high-performance solution to do it, rather than querying all the documents and calculating the array count
regards
The text was updated successfully, but these errors were encountered: