From 5d55ebd54272a0e2658c5289dabd7f2e0f0a4df5 Mon Sep 17 00:00:00 2001 From: rustagir Date: Fri, 23 Aug 2024 15:01:06 -0400 Subject: [PATCH 1/5] DOCSP-42818: wherelike and wherenotlike docs --- .../query-builder/QueryBuilderTest.php | 12 ++++++ .../query-builder/sample_mflix.movies.json | 5 +++ docs/query-builder.txt | 39 +++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/docs/includes/query-builder/QueryBuilderTest.php b/docs/includes/query-builder/QueryBuilderTest.php index 74f576e32..46822f257 100644 --- a/docs/includes/query-builder/QueryBuilderTest.php +++ b/docs/includes/query-builder/QueryBuilderTest.php @@ -374,6 +374,18 @@ public function testWhereRegex(): void $this->assertInstanceOf(\Illuminate\Support\Collection::class, $result); } + public function testWhereLike(): void + { + // begin query whereLike + $result = DB::connection('mongodb') + ->table('movies') + ->whereLike('title', 'Start%', true) + ->get(); + // end query whereLike + + $this->assertInstanceOf(\Illuminate\Support\Collection::class, $result); + } + public function testWhereRaw(): void { // begin query raw diff --git a/docs/includes/query-builder/sample_mflix.movies.json b/docs/includes/query-builder/sample_mflix.movies.json index ef8677520..2d5f45e6d 100644 --- a/docs/includes/query-builder/sample_mflix.movies.json +++ b/docs/includes/query-builder/sample_mflix.movies.json @@ -148,6 +148,11 @@ } } }, + { + "runtime": 120, + "directors": ["Alan Pakula"], + "title": "Starting Over" + }, { "genres": ["Crime", "Drama"], "runtime": 119, diff --git a/docs/query-builder.txt b/docs/query-builder.txt index 45e3c5993..10642290e 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -847,6 +847,45 @@ To learn more about regular expression queries in MongoDB, see :manual:`$regex ` in the {+server-docs-name+}. +whereLike() and whereNotLike() Methods +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can perform queries to match string patterns by using the +following methods: + +- ``whereLike()``: Matches a specified pattern. By default, this method + performs a case-insensitive match. You can enable case-sensitivity by + passing ``true`` as the last parameter to the method. +- ``whereNotLike()``: Matches documents in which the field + value does not contain the specified string pattern. + +The following example shows how to use the ``whereLike()`` method to +match documents in which the ``title`` field has a value that matches the +pattern ``'Start%'`` with case-sensitivity enabled: + +.. literalinclude:: /includes/query-builder/QueryBuilderTest.php + :language: php + :dedent: + :start-after: begin query whereLike + :end-before: end query whereLike + +The preceding query matches documents with the following ``title`` +field values: + +.. code-block:: none + + Start-Up + Start the Revolution Without Me + Starting Over + +The query doesn't match the following ``title`` values: + +.. code-block:: none + + Restart + starting over + I Start Counting + .. _laravel-query-builder-whereRaw: Run MongoDB Query API Operations Example From 6654a80b6211b31619b4bde80d36cf4fadd1c87b Mon Sep 17 00:00:00 2001 From: rustagir Date: Fri, 23 Aug 2024 15:06:14 -0400 Subject: [PATCH 2/5] heading fix --- docs/query-builder.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/query-builder.txt b/docs/query-builder.txt index 10642290e..1c40bd107 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -848,7 +848,7 @@ To learn more about regular expression queries in MongoDB, see in the {+server-docs-name+}. whereLike() and whereNotLike() Methods -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can perform queries to match string patterns by using the following methods: From e21950b8ca7e1cc14e7d76a6dc4877fc8cfb44ce Mon Sep 17 00:00:00 2001 From: rustagir Date: Fri, 23 Aug 2024 15:09:53 -0400 Subject: [PATCH 3/5] move section --- docs/query-builder.txt | 74 ++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/docs/query-builder.txt b/docs/query-builder.txt index 1c40bd107..455e4b8b7 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -381,6 +381,41 @@ wildcard characters: ... ] +whereLike() and whereNotLike() Methods +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can perform queries to match string patterns by using the +following methods: + +- ``whereLike()``: Matches a specified pattern. By default, this method + performs a case-insensitive match. You can enable case-sensitivity by + passing ``true`` as the last parameter to the method. +- ``whereNotLike()``: Matches documents in which the field + value does not contain the specified string pattern. + +The following example shows how to use the ``whereLike()`` method to +match documents in which the ``title`` field has a value that matches the +pattern ``'Start%'`` with case-sensitivity enabled: + +.. io-code-block:: + :copyable: true + + .. input:: /includes/query-builder/QueryBuilderTest.php + :language: php + :dedent: + :start-after: begin query whereLike + :end-before: end query whereLike + + .. output:: + :language: json + :visible: false + + [ + { "title": "Start-Up", ... }, + { "title": "Start the Revolution Without Me", ... }, + ... + ] + .. _laravel-query-builder-distinct: Retrieve Distinct Values @@ -847,45 +882,6 @@ To learn more about regular expression queries in MongoDB, see :manual:`$regex ` in the {+server-docs-name+}. -whereLike() and whereNotLike() Methods -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -You can perform queries to match string patterns by using the -following methods: - -- ``whereLike()``: Matches a specified pattern. By default, this method - performs a case-insensitive match. You can enable case-sensitivity by - passing ``true`` as the last parameter to the method. -- ``whereNotLike()``: Matches documents in which the field - value does not contain the specified string pattern. - -The following example shows how to use the ``whereLike()`` method to -match documents in which the ``title`` field has a value that matches the -pattern ``'Start%'`` with case-sensitivity enabled: - -.. literalinclude:: /includes/query-builder/QueryBuilderTest.php - :language: php - :dedent: - :start-after: begin query whereLike - :end-before: end query whereLike - -The preceding query matches documents with the following ``title`` -field values: - -.. code-block:: none - - Start-Up - Start the Revolution Without Me - Starting Over - -The query doesn't match the following ``title`` values: - -.. code-block:: none - - Restart - starting over - I Start Counting - .. _laravel-query-builder-whereRaw: Run MongoDB Query API Operations Example From 7dd006f3b3e438eed20a8679208fc715f197fb08 Mon Sep 17 00:00:00 2001 From: rustagir Date: Fri, 23 Aug 2024 15:10:55 -0400 Subject: [PATCH 4/5] wip --- docs/query-builder.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/query-builder.txt b/docs/query-builder.txt index 455e4b8b7..e9677725b 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -384,8 +384,8 @@ wildcard characters: whereLike() and whereNotLike() Methods ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -You can perform queries to match string patterns by using the -following methods: +The following methods provide the same functionality as using the +``like`` query operator to match patterns: - ``whereLike()``: Matches a specified pattern. By default, this method performs a case-insensitive match. You can enable case-sensitivity by From 99dc470ee658eb7e166199c4273970e113f50415 Mon Sep 17 00:00:00 2001 From: rustagir Date: Mon, 26 Aug 2024 15:06:20 -0400 Subject: [PATCH 5/5] add cross link --- docs/query-builder.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/query-builder.txt b/docs/query-builder.txt index e9677725b..7d33c016d 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -385,7 +385,8 @@ whereLike() and whereNotLike() Methods ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The following methods provide the same functionality as using the -``like`` query operator to match patterns: +:ref:`like ` query operator to match +patterns: - ``whereLike()``: Matches a specified pattern. By default, this method performs a case-insensitive match. You can enable case-sensitivity by