# Query

### Usage

```javascript
const params = {
  limit:        <int>,
  offset:       <int>,
  forceRefresh: <boolean>,
  operator:     <string>
}

const query = [
  {
    prop:     <string>,
    operator: <string>,
    value:    <string>
  }
]

unomi.profile.query(params, query);
```

### Response

```javascript
{
  "success": <boolean>,
  "status":  <int>,
  "data":    {
    "list": [<object>]
  }
}
```

### Valid Query Operators

* `all`
* `contains`
* `endsWith`
* `equals`
* `exists`
* `greaterThan`
* `greaterThanOrEqualTo`
* `in`
* `isDay`
* `isNotDay`
* `lessThan`
* `lessThanOrEqualTo`
* `between`
* `mathcesRegex`
* `missing`
* `notEquals`
* `notIn`
* `startsWith`

### Real World Example

```javascript
const params = {
  limit:        10,
  offset:       0,
  forceRefresh: true,
  operator:     "and"
}

const query = [
  {
    prop:     "properties.firstName",
    operator: "equals",
    value:    "John"
  },
  {
    prop:     "properties.lastName",
    operator: "equals",
    value:    "Doe"
  }
]

async function getProfiles() {
  try {
    
    const { data: { list } } = await unomi.profile.query(params, query);
    
    list.forEach((profile) => {
      console.log(`Hello ${profile.properties.firstName}!`);
    });
    
  } catch (err) {
    console.error("An error occurred while getting profiles");
    console.error(err);
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://micheleriva.gitbook.io/unomi-node/api/profile/query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
