Skip to content
Open
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 @@ -12,7 +12,8 @@ import CodeBlock from '@theme/CodeBlock';

* In this page:
* [Create subscription - for all documents in a collection](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---for-all-documents-in-a-collection)
* [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents)
* [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents)
* [Create subscription - filter documents using regex](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents-using-regex)
* [Create subscription - filter and project fields](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-and-project-fields)
* [Create subscription - project data from a related document](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---project-data-from-a-related-document)
* [Create subscription - include documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---include-documents)
Expand Down Expand Up @@ -88,6 +89,56 @@ Only documents that match this condition will be sent from the server to a clien



## Create subscription - filter documents using regex

Here we create a subscription for documents from the _Orders_ collection where the `ShipTo.City` field matches a regular expression pattern.
You can use `Regex.IsMatch` within the subscription's LINQ filter expression to perform server-side pattern matching.

<Tabs groupId='languageSyntax'>
<TabItem value="Generic-syntax" label="Generic-syntax">
<CodeBlock language="csharp">
{`// Filter using Regex.IsMatch in the subscription's LINQ filter
subscriptionName = store.Subscriptions.Create<Order>(x =>
Regex.IsMatch(x.ShipTo.City, "^New"));
`}
</CodeBlock>
</TabItem>
<TabItem value="RQL-syntax" label="RQL-syntax">
<CodeBlock language="csharp">
{`subscriptionName = store.Subscriptions.Create(new SubscriptionCreationOptions()
{
Query = @"From Orders
Where regex(ShipTo.City, '^New')"
});
`}
</CodeBlock>
</TabItem>
</Tabs>

You can pass supported `RegexOptions` as a third argument:

<CodeBlock language="csharp">
{`// Filter with case-insensitive regex matching
subscriptionName = store.Subscriptions.Create<Order>(x =>
Regex.IsMatch(x.ShipTo.City, "^new", RegexOptions.IgnoreCase));
`}
</CodeBlock>

<Admonition type="note" title="Supported RegexOptions">

The following `RegexOptions` are supported:
* `RegexOptions.IgnoreCase`
* `RegexOptions.Multiline`
* `RegexOptions.Singleline`

Other `RegexOptions` values (e.g. `Compiled`, `ExplicitCapture`) and the timeout overload are **not supported** and will throw a `NotSupportedException`.

The regex pattern must be a **constant expression** — it cannot be a variable computed at runtime from document fields.

</Admonition>



## Create subscription - filter and project fields

Here, again, we create a subscription for documents from the _Orders_ collection where the total order revenue is greater than 100.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import CodeBlock from '@theme/CodeBlock';

* In this page:
* [Create subscription - for all documents in a collection](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---for-all-documents-in-a-collection)
* [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents)
* [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents)
* [Create subscription - filter documents using regex](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents-using-regex)
* [Create subscription - filter and project fields](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-and-project-fields)
* [Create subscription - project data from a related document](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---project-data-from-a-related-document)
* [Create subscription - include documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---include-documents)
Expand Down Expand Up @@ -92,6 +93,22 @@ const subscriptionName = await documentStore.subscriptions.create(\{ query \});



## Create subscription - filter documents using regex

Here we create a subscription for documents from the _Orders_ collection where the `ShipTo.City` field matches a regular expression pattern.
Use the RQL `regex` function to perform server-side pattern matching.

<TabItem value="create_filter_regex" label="create_filter_regex">
<CodeBlock language="js">
{`const query = \`from Orders where regex(ShipTo.City, '^New')\`;

const subscriptionName = await documentStore.subscriptions.create(\{ query \});
`}
</CodeBlock>
</TabItem>



## Create subscription - filter and project fields

Here, again, we create a subscription for documents from the _Orders_ collection where the total order revenue is greater than 100.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import CodeBlock from '@theme/CodeBlock';
* In this page:
* [Create subscription - for all documents in a collection](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---for-all-documents-in-a-collection)
* [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents)
* [Create subscription - filter documents using regex](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents-using-regex)
* [Create subscription - filter and project fields](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-and-project-fields)
* [Create subscription - project data from a related document](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---project-data-from-a-related-document)
* [Create subscription - include documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---include-documents)
Expand Down Expand Up @@ -72,6 +73,24 @@ Only documents that match this condition will be sent from the server to a clien



## Create subscription - filter documents using regex

Here we create a subscription for documents from the _Orders_ collection where the `ShipTo.City` field matches a regular expression pattern.
Use the RQL `regex` function to perform server-side pattern matching.

<TabItem value="create_filter_regex_RQL" label="create_filter_regex_RQL">
<CodeBlock language="python">
{`name = store.subscriptions.create_for_options(
SubscriptionCreationOptions(
query="From Orders Where regex(ShipTo.City, '^New')"
),
)
`}
</CodeBlock>
</TabItem>



## Create subscription - filter and project fields

Here, again, we create a subscription for documents from the _Orders_ collection where the total order revenue is greater than 100.
Expand Down
Loading