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

[PHP] Client API Operations batch 1 [Replace C# samples] #1935

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Use `DeleteByQueryOperation` to delete a large number of documents that match the provided query in a single server call.

* **Dynamic behavior**:
The deletion of documents matching the specified query is run in batches of size 1024.
The deletion of documents matching the specified query is performed in batches of size 1024.
During the deletion process, documents that are added/modified **after** the delete operation has started
may also be deleted if they match the query criteria.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

* Use `DeleteByQueryOperation` to delete a large number of documents that match the provided query in a single server call.

* __Dynamic behavior__:
The deletion of documents matching the specified query is run in batches of size 1024.
During the deletion process, documents that are added/modified __after__ the delete operation has started
* **Dynamic behavior**:
The deletion of documents matching the specified query is performed in batches of size 1024.
During the deletion process, documents that are added/modified **after** the delete operation has started
may also be deleted if they match the query criteria.

* __Background operation__:
* **Background operation**:
This operation is performed in the background on the server.
If needed, you can __wait__ for the operation to complete. See: [Wait for completion](../../../client-api/operations/what-are-operations#wait-for-completion).
If needed, you can **wait** for the operation to complete. See: [Wait for completion](../../../client-api/operations/what-are-operations#wait-for-completion).

* In this page:
* [Delete by dynamic query](../../../client-api/operations/common/delete-by-query#delete-by-dynamic-query)
Expand All @@ -25,7 +25,7 @@

{NOTE: }

__Delete all documents in collection__:
**Delete all documents in collection**:

{CODE-TABS}
{CODE-TAB:nodejs:DeleteOperation delete_by_query_0@client-api\Operations\Common\deleteByQuery.js /}
Expand All @@ -38,7 +38,7 @@ from "Orders"

{NOTE: }

__Delete with filtering__:
**Delete with filtering**:

{CODE-TABS}
{CODE-TAB:nodejs:DeleteOperation delete_by_query_1@client-api\Operations\Common\deleteByQuery.js /}
Expand All @@ -53,7 +53,7 @@ from "Orders" where Freight > 30

{PANEL: Delete by index query}

* `DeleteByQueryOperation` can only be performed on a __Map-index__.
* `DeleteByQueryOperation` can only be performed on a **Map-index**.
An exception is thrown when executing the operation on a Map-Reduce index.

* A few overloads are available, see the following examples:
Expand All @@ -62,15 +62,15 @@ from "Orders" where Freight > 30

{NOTE: }

__A sample Map-index__:
**A sample Map-index**:

{CODE:nodejs the_index@client-api\Operations\Common\deleteByQuery.js /}

{NOTE/}

{NOTE: }

__Delete documents via an index query__:
**Delete documents via an index query**:

{CODE-TABS}
{CODE-TAB:nodejs:DeleteOperation delete_by_query_2@client-api\Operations\Common\deleteByQuery.js /}
Expand All @@ -84,7 +84,7 @@ from index "Products/ByPrice" where Price > 10

{NOTE: }

__Delete with options__:
**Delete with options**:

{CODE-TABS}
{CODE-TAB:nodejs:DeleteOperation delete_by_query_4@client-api\Operations\Common\deleteByQuery.js /}
Expand All @@ -106,9 +106,9 @@ from index "Products/ByPrice" where Price > 10

| Parameter | Type | Description |
|-------------------|-----------------------------|------------------------------------------------------------|
| __queryToDelete__ | string | The RQL query to perform |
| __queryToDelete__ | `IndexQuery` | Holds all the information required to query an index |
| __options__ | `object` | Object holding different setting options for the operation |
| **queryToDelete** | `string` | The RQL query to perform |
| **queryToDelete** | `IndexQuery` | Holds all the information required to query an index |
| **options** | `object` | Object holding different setting options for the operation |

{CODE:nodejs syntax_2@client-api\Operations\Common\DeleteByQuery.js /}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Delete by Query Operation
---

{NOTE: }

* Use `DeleteByQueryOperation` to delete a large number of documents that match the provided query in a single server call.

* **Dynamic behavior**:
The deletion of documents matching the specified query is performed in batches of size 1024.
During the deletion process, documents that are added/modified **after** the delete operation has started
may also be deleted if they match the query criteria.

* **Background operation**:
This operation is performed in the background on the server.

* In this page:
* [Delete by dynamic query](../../../client-api/operations/common/delete-by-query#delete-by-dynamic-query)
* [Delete by index query](../../../client-api/operations/common/delete-by-query#delete-by-index-query)
* [Syntax](../../../client-api/operations/common/delete-by-query#syntax)

{NOTE/}

{PANEL: Delete by dynamic query}

#### Delete all documents in a collection:

{CODE-TABS}
{CODE-TAB:php:DeleteByQueryOperation delete_by_query_0@ClientApi\Operations\Common\DeleteByQuery.php /}
{CODE-TAB-BLOCK:sql:RQL}
from "Orders"
{CODE-TAB-BLOCK/}
{CODE-TABS/}

---

#### Delete with filtering:

{CODE-TABS}
{CODE-TAB:php:DeleteByQueryOperation delete_by_query_1@ClientApi\Operations\Common\DeleteByQuery.php /}
{CODE-TAB-BLOCK:sql:RQL}
from "Orders" where Freight > 30
{CODE-TAB-BLOCK/}
{CODE-TABS/}

{PANEL/}

{PANEL: Delete by index query}

* `DeleteByQueryOperation` can only be performed on a **Map-index**.
An exception is thrown when executing the operation on a Map-Reduce index.

* A few overloads are available, see the following examples:

---

#### A sample Map-index:

{CODE:php the_index@ClientApi\Operations\Common\DeleteByQuery.php /}

---

#### Delete documents via an index query:

{CODE-TABS}
{CODE-TAB:php:RQL delete_by_query_2@ClientApi\Operations\Common\DeleteByQuery.php /}
{CODE-TAB:php:IndexQuery delete_by_query_3@ClientApi\Operations\Common\DeleteByQuery.php /}
{CODE-TAB-BLOCK:sql:RQL}
from index "Products/ByPrice" where Price > 10
{CODE-TAB-BLOCK/}
{CODE-TABS/}

---

#### Delete with options:

{CODE-TABS}
{CODE-TAB:php:QueryOperationOptions delete_by_query_6@ClientApi\Operations\Common\DeleteByQuery.php /}
{CODE-TAB-BLOCK:sql:RQL}
from index "Products/ByPrice" where Price > 10
{CODE-TAB-BLOCK/}
{CODE-TABS/}

{PANEL/}

{PANEL: Syntax}

{CODE:php syntax_1@ClientApi\Operations\Common\DeleteByQuery.php /}
<br />

| Parameter | Type | Description |
|-------------------|---------------------------|--------------------------|
| **$queryToDelete** | `string` | The RQL query to perform |
| **$queryToDelete** | `IndexQuery` | Holds all the information required to query an index |
| **$options** | `?QueryOperationOptions` | Object holding different setting options for the operation |

{CODE:php syntax_2@ClientApi\Operations\Common\DeleteByQuery.php /}

{PANEL/}


## Related Articles

### Operations

- [What are Operations](../../../client-api/operations/what-are-operations)

### Client API

- [How to Query](../../../client-api/session/querying/how-to-query)

### Querying

- [What is RQL](../../../client-api/session/querying/what-is-rql)
- [Querying an index](../../../indexes/querying/query-index)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Use `DeleteByQueryOperation` to delete a large number of documents that match the provided query in a single server call.

* **Dynamic behavior**:
The deletion of documents matching the specified query is run in batches of size 1024.
The deletion of documents matching the specified query is performed in batches of size 1024.
During the deletion process, documents that are added/modified **after** the delete operation has started
may also be deleted if they match the query criteria.

Expand Down
Loading
Loading