# Query for Get Data

> Perform complex queries to retrieve data from a collection with filtering, sorting, and pagination using API Maker.

Source: https://docs.apimaker.dev/v4/examples/sys/db/query.html

> **The code in every language**
>
> Each example is the inside of `main`, written in every [language](https://docs.apimaker.dev/v4/docs/languages/index.html) API Maker runs : pick yours in the tabs, and every page shows it from then on. The types a call takes (`GetAll`, `DeepItem`…) are those of `am` : `from am import GetAll` in Python, `use am::GetAll;` in Rust, `import am.GetAll;` in Java and Kotlin ; PHP and C# have them without an import, Go names them `am.GetAll`.

## Simple query

**TypeScript**

**Simple query to get data**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find:{
        "first_name": "Bob"
    },
});
```

**Python**

**Simple query to get data**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': 'Bob',
    },
)
```

**PHP**

**Simple query to get data**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
);
```

**C#**

**Simple query to get data**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
});
```

**Go**

**Simple query to get data**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**Simple query to get data**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "Bob",
        })),
)?;
```

**Java**

**Simple query to get data**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "Bob"
    )));
```

**Kotlin**

**Simple query to get data**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        )),
)
```

## query [headers]

**TypeScript**

**query headers**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find:{
        "first_name": "Bob"
    },
    headers: {
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
});
```

**Python**

**query headers**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': 'Bob',
    },
    headers={
        'x-am-response-case': 'capitalCase',  # noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
)
```

**PHP**

**query headers**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
    headers: [
        'x-am-response-case' => 'capitalCase', // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    ],
);
```

**C#**

**query headers**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
    Headers = new JsonObject
    {
        ["x-am-response-case"] = "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    },
});
```

**Go**

**query headers**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
	Headers: am.M{
		"x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**query headers**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "Bob",
        }))
        .headers(json!({
            "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        })),
)?;
```

**Java**

**query headers**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "Bob"
    ))
    .headers(Map.of(
        "x-am-response-case", "capitalCase" // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
    )));
```

**Kotlin**

**query headers**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        ))
        .headers(mapOf(
            "x-am-response-case" to "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        )),
)
```

## query [select]

**TypeScript**

**query select**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find:{
        "first_name": "Bob"
    },
    select: "first_name"
});
```

**Python**

**query select**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': 'Bob',
    },
    select='first_name',
)
```

**PHP**

**query select**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
    select: 'first_name',
);
```

**C#**

**query select**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
    Select = "first_name",
});
```

**Go**

**query select**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
	Select: "first_name",
})
if err != nil {
	return nil, err
}
```

**Rust**

**query select**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "Bob",
        }))
        .select("first_name"),
)?;
```

**Java**

**query select**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "Bob"
    ))
    .select("first_name"));
```

**Kotlin**

**query select**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        ))
        .select("first_name"),
)
```

## query [limit]

**TypeScript**

**query limit**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find:{
        "first_name": "Bob"
    },
    limit: 2
});
```

**Python**

**query limit**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': 'Bob',
    },
    limit=2,
)
```

**PHP**

**query limit**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
    limit: 2,
);
```

**C#**

**query limit**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
    Limit = 2,
});
```

**Go**

**query limit**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
	Limit: 2,
})
if err != nil {
	return nil, err
}
```

**Rust**

**query limit**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "Bob",
        }))
        .limit(2),
)?;
```

**Java**

**query limit**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "Bob"
    ))
    .limit(2));
```

**Kotlin**

**query limit**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        ))
        .limit(2),
)
```

## query [skip]

**TypeScript**

**query skip**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find:{
        "first_name": "Bob"
    },
    skip: 1
});
```

**Python**

**query skip**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': 'Bob',
    },
    skip=1,
)
```

**PHP**

**query skip**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
    skip: 1,
);
```

**C#**

**query skip**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
    Skip = 1,
});
```

**Go**

**query skip**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
	Skip: 1,
})
if err != nil {
	return nil, err
}
```

**Rust**

**query skip**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "Bob",
        }))
        .skip(1),
)?;
```

**Java**

**query skip**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "Bob"
    ))
    .skip(1));
```

**Kotlin**

**query skip**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        ))
        .skip(1),
)
```

## query [sort]

**TypeScript**

**query sort**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find:{
        "first_name": "Bob"
    },
    sort: "first_name"
});
```

**Python**

**query sort**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': 'Bob',
    },
    sort='first_name',
)
```

**PHP**

**query sort**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
    sort: 'first_name',
);
```

**C#**

**query sort**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
    Sort = "first_name",
});
```

**Go**

**query sort**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
	Sort: "first_name",
})
if err != nil {
	return nil, err
}
```

**Rust**

**query sort**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "Bob",
        }))
        .sort("first_name"),
)?;
```

**Java**

**query sort**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "Bob"
    ))
    .sort("first_name"));
```

**Kotlin**

**query sort**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        ))
        .sort("first_name"),
)
```

## query [deep]

**TypeScript**

**query deep**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find:{
        "first_name": "Bob"
    },
    deep: [
        {
            s_key: "customer_id",
            t_instance: "mysql",
            t_db: "inventory",
            t_col: "products",
            t_key: "owner_id",
        }
    ],
});
```

**Python**

**query deep**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': 'Bob',
    },
    deep=[
        DeepItem(
            'customer_id',
            t_instance='mysql',
            t_db='inventory',
            t_col='products',
            t_key='owner_id',
        ),
    ],
)
```

**PHP**

**query deep**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
    deep: [
        new DeepItem(
            'customer_id',
            tInstance: 'mysql',
            tDb: 'inventory',
            tCol: 'products',
            tKey: 'owner_id',
        ),
    ],
);
```

**C#**

**query deep**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
    Deep = new[]
    {
        new DeepItem("customer_id")
        {
            TInstance = "mysql",
            TDb = "inventory",
            TCol = "products",
            TKey = "owner_id",
        },
    },
});
```

**Go**

**query deep**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
	Deep: []am.DeepItem{
		{
			SKey:      "customer_id",
			TInstance: "mysql",
			TDb:       "inventory",
			TCol:      "products",
			TKey:      "owner_id",
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**query deep**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "Bob",
        }))
        .deep(vec![
            DeepItem::new("customer_id")
                .t_instance("mysql")
                .t_db("inventory")
                .t_col("products")
                .t_key("owner_id"),
        ]),
)?;
```

**Java**

**query deep**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "Bob"
    ))
    .deep(List.of(
        new DeepItem("customer_id")
            .tInstance("mysql")
            .tDb("inventory")
            .tCol("products")
            .tKey("owner_id")
    )));
```

**Kotlin**

**query deep**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        ))
        .deep(listOf(
            DeepItem("customer_id")
                .tInstance("mysql")
                .tDb("inventory")
                .tCol("products")
                .tKey("owner_id"),
        )),
)
```

## $lt [less than] query

**TypeScript**

**less than query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        customer_id: {
            "$lt": 2
        }
    }
});
```

**Python**

**less than query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$lt': 2,
        },
    },
)
```

**PHP**

**less than query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$lt' => 2,
        ],
    ],
);
```

**C#**

**less than query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$lt"] = 2,
        },
    },
});
```

**Go**

**less than query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$lt": 2,
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**less than query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$lt": 2,
            },
        })),
)?;
```

**Java**

**less than query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$lt", 2
        )
    )));
```

**Kotlin**

**less than query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$lt" to 2,
            ),
        )),
)
```

## $lte [less than equal] query

**TypeScript**

**less than equal query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        customer_id: {
            "$lte": 2
        }
    }
});
```

**Python**

**less than equal query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$lte': 2,
        },
    },
)
```

**PHP**

**less than equal query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$lte' => 2,
        ],
    ],
);
```

**C#**

**less than equal query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$lte"] = 2,
        },
    },
});
```

**Go**

**less than equal query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$lte": 2,
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**less than equal query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$lte": 2,
            },
        })),
)?;
```

**Java**

**less than equal query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$lte", 2
        )
    )));
```

**Kotlin**

**less than equal query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$lte" to 2,
            ),
        )),
)
```

## $gt [greater than] query

**TypeScript**

**greater than query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        customer_id: {
            "$gt": 2
        }
    }
});
```

**Python**

**greater than query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$gt': 2,
        },
    },
)
```

**PHP**

**greater than query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$gt' => 2,
        ],
    ],
);
```

**C#**

**greater than query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$gt"] = 2,
        },
    },
});
```

**Go**

**greater than query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$gt": 2,
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**greater than query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$gt": 2,
            },
        })),
)?;
```

**Java**

**greater than query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$gt", 2
        )
    )));
```

**Kotlin**

**greater than query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$gt" to 2,
            ),
        )),
)
```

## $gte [greater than equal] query

**TypeScript**

**greater than equal query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        customer_id: {
            "$gte": 2
        }
    }
});
```

**Python**

**greater than equal query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$gte': 2,
        },
    },
)
```

**PHP**

**greater than equal query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$gte' => 2,
        ],
    ],
);
```

**C#**

**greater than equal query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$gte"] = 2,
        },
    },
});
```

**Go**

**greater than equal query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$gte": 2,
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**greater than equal query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$gte": 2,
            },
        })),
)?;
```

**Java**

**greater than equal query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$gte", 2
        )
    )));
```

**Kotlin**

**greater than equal query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$gte" to 2,
            ),
        )),
)
```

## $eq [equal to] query

**TypeScript**

**$eq query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        customer_id: {
            "$eq": 2
        }
    }
});
```

**Python**

**$eq query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$eq': 2,
        },
    },
)
```

**PHP**

**$eq query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$eq' => 2,
        ],
    ],
);
```

**C#**

**$eq query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$eq"] = 2,
        },
    },
});
```

**Go**

**$eq query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$eq": 2,
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$eq query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$eq": 2,
            },
        })),
)?;
```

**Java**

**$eq query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$eq", 2
        )
    )));
```

**Kotlin**

**$eq query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$eq" to 2,
            ),
        )),
)
```

## $ne [not equal to] query

**TypeScript**

**$ne query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        customer_id: {
            "$ne": 2
        }
    }
});
```

**Python**

**$ne query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$ne': 2,
        },
    },
)
```

**PHP**

**$ne query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$ne' => 2,
        ],
    ],
);
```

**C#**

**$ne query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$ne"] = 2,
        },
    },
});
```

**Go**

**$ne query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$ne": 2,
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$ne query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$ne": 2,
            },
        })),
)?;
```

**Java**

**$ne query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$ne", 2
        )
    )));
```

**Kotlin**

**$ne query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$ne" to 2,
            ),
        )),
)
```

## $not [not] query

**TypeScript**

**$not query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        customer_id: {
            "$not": {
                "$in": [1, 2, 3, 4]
            }
        }
    }
});
```

**Python**

**$not query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$not': {
                '$in': [1, 2, 3, 4],
            },
        },
    },
)
```

**PHP**

**$not query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$not' => [
                '$in' => [1, 2, 3, 4],
            ],
        ],
    ],
);
```

**C#**

**$not query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$not"] = new JsonObject
            {
                ["$in"] = new JsonArray { 1, 2, 3, 4 },
            },
        },
    },
});
```

**Go**

**$not query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$not": am.M{
				"$in": []any{1, 2, 3, 4},
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$not query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$not": {
                    "$in": [1, 2, 3, 4],
                },
            },
        })),
)?;
```

**Java**

**$not query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$not", Map.of(
                "$in", List.of(1, 2, 3, 4)
            )
        )
    )));
```

**Kotlin**

**$not query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$not" to mapOf(
                    "\$in" to listOf(1, 2, 3, 4),
                ),
            ),
        )),
)
```

## $and [and] query

**TypeScript**

**$and query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "$and": [
            {
                "customer_id": 2
            },
            {
                "pincode": 7171
            }
        ]
    }
});
```

**Python**

**$and query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        '$and': [
            {
                'customer_id': 2,
            },
            {
                'pincode': 7171,
            },
        ],
    },
)
```

**PHP**

**$and query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        '$and' => [
            [
                'customer_id' => 2,
            ],
            [
                'pincode' => 7171,
            ],
        ],
    ],
);
```

**C#**

**$and query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["$and"] = new JsonArray
        {
            new JsonObject
            {
                ["customer_id"] = 2,
            },
            new JsonObject
            {
                ["pincode"] = 7171,
            },
        },
    },
});
```

**Go**

**$and query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"$and": []any{
			am.M{
				"customer_id": 2,
			},
			am.M{
				"pincode": 7171,
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$and query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "$and": [
                {
                    "customer_id": 2,
                },
                {
                    "pincode": 7171,
                },
            ],
        })),
)?;
```

**Java**

**$and query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "$and", List.of(
            Map.of(
                "customer_id", 2
            ),
            Map.of(
                "pincode", 7171
            )
        )
    )));
```

**Kotlin**

**$and query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "\$and" to listOf(
                mapOf(
                    "customer_id" to 2,
                ),
                mapOf(
                    "pincode" to 7171,
                ),
            ),
        )),
)
```

Find-join example

**TypeScript**

**find join $and query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "$and": [
            {
                "first_name.customer_id.shipping_id": 2
            },
            {
                "first_name.customer_id.order_id": 58
            }
        ]
    }
});
```

**Python**

**find join $and query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        '$and': [
            {
                'first_name.customer_id.shipping_id': 2,
            },
            {
                'first_name.customer_id.order_id': 58,
            },
        ],
    },
)
```

**PHP**

**find join $and query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        '$and' => [
            [
                'first_name.customer_id.shipping_id' => 2,
            ],
            [
                'first_name.customer_id.order_id' => 58,
            ],
        ],
    ],
);
```

**C#**

**find join $and query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["$and"] = new JsonArray
        {
            new JsonObject
            {
                ["first_name.customer_id.shipping_id"] = 2,
            },
            new JsonObject
            {
                ["first_name.customer_id.order_id"] = 58,
            },
        },
    },
});
```

**Go**

**find join $and query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"$and": []any{
			am.M{
				"first_name.customer_id.shipping_id": 2,
			},
			am.M{
				"first_name.customer_id.order_id": 58,
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**find join $and query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "$and": [
                {
                    "first_name.customer_id.shipping_id": 2,
                },
                {
                    "first_name.customer_id.order_id": 58,
                },
            ],
        })),
)?;
```

**Java**

**find join $and query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "$and", List.of(
            Map.of(
                "first_name.customer_id.shipping_id", 2
            ),
            Map.of(
                "first_name.customer_id.order_id", 58
            )
        )
    )));
```

**Kotlin**

**find join $and query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "\$and" to listOf(
                mapOf(
                    "first_name.customer_id.shipping_id" to 2,
                ),
                mapOf(
                    "first_name.customer_id.order_id" to 58,
                ),
            ),
        )),
)
```

## $or [or] query

**TypeScript**

**$or query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "$or": [
            {
                "customer_id": 2
            },
            {
                "pincode": 7171
            }
        ]
    }
});
```

**Python**

**$or query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        '$or': [
            {
                'customer_id': 2,
            },
            {
                'pincode': 7171,
            },
        ],
    },
)
```

**PHP**

**$or query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        '$or' => [
            [
                'customer_id' => 2,
            ],
            [
                'pincode' => 7171,
            ],
        ],
    ],
);
```

**C#**

**$or query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["$or"] = new JsonArray
        {
            new JsonObject
            {
                ["customer_id"] = 2,
            },
            new JsonObject
            {
                ["pincode"] = 7171,
            },
        },
    },
});
```

**Go**

**$or query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"$or": []any{
			am.M{
				"customer_id": 2,
			},
			am.M{
				"pincode": 7171,
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$or query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "$or": [
                {
                    "customer_id": 2,
                },
                {
                    "pincode": 7171,
                },
            ],
        })),
)?;
```

**Java**

**$or query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "$or", List.of(
            Map.of(
                "customer_id", 2
            ),
            Map.of(
                "pincode", 7171
            )
        )
    )));
```

**Kotlin**

**$or query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "\$or" to listOf(
                mapOf(
                    "customer_id" to 2,
                ),
                mapOf(
                    "pincode" to 7171,
                ),
            ),
        )),
)
```

Find-join example

**TypeScript**

**find join $or query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "$or": [
            {
                "first_name.customer_id.shipping_id": 2
            },
            {
                "first_name.customer_id.order_id": 58
            }
        ]
    }
});
```

**Python**

**find join $or query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        '$or': [
            {
                'first_name.customer_id.shipping_id': 2,
            },
            {
                'first_name.customer_id.order_id': 58,
            },
        ],
    },
)
```

**PHP**

**find join $or query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        '$or' => [
            [
                'first_name.customer_id.shipping_id' => 2,
            ],
            [
                'first_name.customer_id.order_id' => 58,
            ],
        ],
    ],
);
```

**C#**

**find join $or query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["$or"] = new JsonArray
        {
            new JsonObject
            {
                ["first_name.customer_id.shipping_id"] = 2,
            },
            new JsonObject
            {
                ["first_name.customer_id.order_id"] = 58,
            },
        },
    },
});
```

**Go**

**find join $or query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"$or": []any{
			am.M{
				"first_name.customer_id.shipping_id": 2,
			},
			am.M{
				"first_name.customer_id.order_id": 58,
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**find join $or query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "$or": [
                {
                    "first_name.customer_id.shipping_id": 2,
                },
                {
                    "first_name.customer_id.order_id": 58,
                },
            ],
        })),
)?;
```

**Java**

**find join $or query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "$or", List.of(
            Map.of(
                "first_name.customer_id.shipping_id", 2
            ),
            Map.of(
                "first_name.customer_id.order_id", 58
            )
        )
    )));
```

**Kotlin**

**find join $or query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "\$or" to listOf(
                mapOf(
                    "first_name.customer_id.shipping_id" to 2,
                ),
                mapOf(
                    "first_name.customer_id.order_id" to 58,
                ),
            ),
        )),
)
```

## $in [in] query

**TypeScript**

**$in query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "customer_id": {
            "$in": [1, 2]
        }
    }
});
```

**Python**

**$in query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$in': [1, 2],
        },
    },
)
```

**PHP**

**$in query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$in' => [1, 2],
        ],
    ],
);
```

**C#**

**$in query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$in"] = new JsonArray { 1, 2 },
        },
    },
});
```

**Go**

**$in query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$in": []any{1, 2},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$in query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$in": [1, 2],
            },
        })),
)?;
```

**Java**

**$in query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$in", List.of(1, 2)
        )
    )));
```

**Kotlin**

**$in query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$in" to listOf(1, 2),
            ),
        )),
)
```

## $nin [not in] query

**TypeScript**

**$nin query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "customer_id": {
            "$nin": [1, 2]
        }
    }
});
```

**Python**

**$nin query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'customer_id': {
            '$nin': [1, 2],
        },
    },
)
```

**PHP**

**$nin query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'customer_id' => [
            '$nin' => [1, 2],
        ],
    ],
);
```

**C#**

**$nin query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["customer_id"] = new JsonObject
        {
            ["$nin"] = new JsonArray { 1, 2 },
        },
    },
});
```

**Go**

**$nin query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"customer_id": am.M{
			"$nin": []any{1, 2},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$nin query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "customer_id": {
                "$nin": [1, 2],
            },
        })),
)?;
```

**Java**

**$nin query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "customer_id", Map.of(
            "$nin", List.of(1, 2)
        )
    )));
```

**Kotlin**

**$nin query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "customer_id" to mapOf(
                "\$nin" to listOf(1, 2),
            ),
        )),
)
```

## $like [like] query

**TypeScript**

**$like query**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "first_name": {
            "$like": "Bob%"
        }
    }
});
```

**Python**

**$like query**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': {
            '$like': 'Bob%',
        },
    },
)
```

**PHP**

**$like query**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => [
            '$like' => 'Bob%',
        ],
    ],
);
```

**C#**

**$like query**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = new JsonObject
        {
            ["$like"] = "Bob%",
        },
    },
});
```

**Go**

**$like query**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": am.M{
			"$like": "Bob%",
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$like query**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": {
                "$like": "Bob%",
            },
        })),
)?;
```

**Java**

**$like query**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", Map.of(
            "$like", "Bob%"
        )
    )));
```

**Kotlin**

**$like query**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to mapOf(
                "\$like" to "Bob%",
            ),
        )),
)
```

## $isNull [null check] with sql databases

**TypeScript**

**$isNull use**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "first_name": {
            "$isNull": true
        }
    }
});
```

**Python**

**$isNull use**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'first_name': {
            '$isNull': True,
        },
    },
)
```

**PHP**

**$isNull use**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'first_name' => [
            '$isNull' => true,
        ],
    ],
);
```

**C#**

**$isNull use**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = new JsonObject
        {
            ["$isNull"] = true,
        },
    },
});
```

**Go**

**$isNull use**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"first_name": am.M{
			"$isNull": true,
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$isNull use**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": {
                "$isNull": true,
            },
        })),
)?;
```

**Java**

**$isNull use**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", Map.of(
            "$isNull", true
        )
    )));
```

**Kotlin**

**$isNull use**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to mapOf(
                "\$isNull" to true,
            ),
        )),
)
```

## MongoDB $in operator in nested find

**TypeScript**

**$in operator in nested find**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "eventListeners.versions.name": {
            "$in": [
                "Original",
                "1"
            ]
        }
    }
});
```

**Python**

**$in operator in nested find**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'eventListeners.versions.name': {
            '$in': [
                'Original',
                '1',
            ],
        },
    },
)
```

**PHP**

**$in operator in nested find**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'eventListeners.versions.name' => [
            '$in' => [
                'Original',
                '1',
            ],
        ],
    ],
);
```

**C#**

**$in operator in nested find**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["eventListeners.versions.name"] = new JsonObject
        {
            ["$in"] = new JsonArray
            {
                "Original",
                "1",
            },
        },
    },
});
```

**Go**

**$in operator in nested find**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"eventListeners.versions.name": am.M{
			"$in": []string{
				"Original",
				"1",
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$in operator in nested find**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "eventListeners.versions.name": {
                "$in": [
                    "Original",
                    "1",
                ],
            },
        })),
)?;
```

**Java**

**$in operator in nested find**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "eventListeners.versions.name", Map.of(
            "$in", List.of(
                "Original",
                "1"
            )
        )
    )));
```

**Kotlin**

**$in operator in nested find**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "eventListeners.versions.name" to mapOf(
                "\$in" to listOf(
                    "Original",
                    "1",
                ),
            ),
        )),
)
```

## MongoDB $nin operator in nested find

**TypeScript**

**$nin operator in nested find**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "eventListeners.versions.name": {
            "$nin": [
                "Original",
                "1"
            ]
        }
    }
});
```

**Python**

**$nin operator in nested find**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        'eventListeners.versions.name': {
            '$nin': [
                'Original',
                '1',
            ],
        },
    },
)
```

**PHP**

**$nin operator in nested find**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        'eventListeners.versions.name' => [
            '$nin' => [
                'Original',
                '1',
            ],
        ],
    ],
);
```

**C#**

**$nin operator in nested find**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["eventListeners.versions.name"] = new JsonObject
        {
            ["$nin"] = new JsonArray
            {
                "Original",
                "1",
            },
        },
    },
});
```

**Go**

**$nin operator in nested find**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"eventListeners.versions.name": am.M{
			"$nin": []string{
				"Original",
				"1",
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$nin operator in nested find**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "eventListeners.versions.name": {
                "$nin": [
                    "Original",
                    "1",
                ],
            },
        })),
)?;
```

**Java**

**$nin operator in nested find**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "eventListeners.versions.name", Map.of(
            "$nin", List.of(
                "Original",
                "1"
            )
        )
    )));
```

**Kotlin**

**$nin operator in nested find**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "eventListeners.versions.name" to mapOf(
                "\$nin" to listOf(
                    "Original",
                    "1",
                ),
            ),
        )),
)
```

## MongoDB $and operator in nested find

**TypeScript**

**$and operator in nested find**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "$and": [
            {
                "eventListeners.versions.name": "Original"
            },
            {
                "eventListeners.versions.version": "-1"
            }
        ]
    }
});
```

**Python**

**$and operator in nested find**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        '$and': [
            {
                'eventListeners.versions.name': 'Original',
            },
            {
                'eventListeners.versions.version': '-1',
            },
        ],
    },
)
```

**PHP**

**$and operator in nested find**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        '$and' => [
            [
                'eventListeners.versions.name' => 'Original',
            ],
            [
                'eventListeners.versions.version' => '-1',
            ],
        ],
    ],
);
```

**C#**

**$and operator in nested find**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["$and"] = new JsonArray
        {
            new JsonObject
            {
                ["eventListeners.versions.name"] = "Original",
            },
            new JsonObject
            {
                ["eventListeners.versions.version"] = "-1",
            },
        },
    },
});
```

**Go**

**$and operator in nested find**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"$and": []any{
			am.M{
				"eventListeners.versions.name": "Original",
			},
			am.M{
				"eventListeners.versions.version": "-1",
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$and operator in nested find**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "$and": [
                {
                    "eventListeners.versions.name": "Original",
                },
                {
                    "eventListeners.versions.version": "-1",
                },
            ],
        })),
)?;
```

**Java**

**$and operator in nested find**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "$and", List.of(
            Map.of(
                "eventListeners.versions.name", "Original"
            ),
            Map.of(
                "eventListeners.versions.version", "-1"
            )
        )
    )));
```

**Kotlin**

**$and operator in nested find**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "\$and" to listOf(
                mapOf(
                    "eventListeners.versions.name" to "Original",
                ),
                mapOf(
                    "eventListeners.versions.version" to "-1",
                ),
            ),
        )),
)
```

## MongoDB $or operator in nested find

**TypeScript**

**$or operator in nested find**

```typescript
let query = await g.sys.db.query({
    instance: "mysql_8", database: "inventory", collection: "customers",
    find: {
        "$or": [
            {
                "eventListeners.versions.name": "Original"
            },
            {
                "eventListeners.versions.version": "-1"
            }
        ]
    }
});
```

**Python**

**$or operator in nested find**

```python
query = await g.sys.db.query(
    'mysql_8', 'inventory', 'customers',
    find={
        '$or': [
            {
                'eventListeners.versions.name': 'Original',
            },
            {
                'eventListeners.versions.version': '-1',
            },
        ],
    },
)
```

**PHP**

**$or operator in nested find**

```php
$query = $g->sys->db->query(
    'mysql_8', 'inventory', 'customers',
    find: [
        '$or' => [
            [
                'eventListeners.versions.name' => 'Original',
            ],
            [
                'eventListeners.versions.version' => '-1',
            ],
        ],
    ],
);
```

**C#**

**$or operator in nested find**

```csharp
var query = await g.Sys.Db.Query(new Query("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["$or"] = new JsonArray
        {
            new JsonObject
            {
                ["eventListeners.versions.name"] = "Original",
            },
            new JsonObject
            {
                ["eventListeners.versions.version"] = "-1",
            },
        },
    },
});
```

**Go**

**$or operator in nested find**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	Find: am.M{
		"$or": []any{
			am.M{
				"eventListeners.versions.name": "Original",
			},
			am.M{
				"eventListeners.versions.version": "-1",
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**$or operator in nested find**

```rust
let query = g.sys.db.query(
    Query::new("mysql_8", "inventory", "customers")
        .find(json!({
            "$or": [
                {
                    "eventListeners.versions.name": "Original",
                },
                {
                    "eventListeners.versions.version": "-1",
                },
            ],
        })),
)?;
```

**Java**

**$or operator in nested find**

```java
var query = g.sys.db.query(new Query("mysql_8", "inventory", "customers")
    .find(Map.of(
        "$or", List.of(
            Map.of(
                "eventListeners.versions.name", "Original"
            ),
            Map.of(
                "eventListeners.versions.version", "-1"
            )
        )
    )));
```

**Kotlin**

**$or operator in nested find**

```kotlin
val query = g.sys.db.query(
    Query("mysql_8", "inventory", "customers")
        .find(mapOf(
            "\$or" to listOf(
                mapOf(
                    "eventListeners.versions.name" to "Original",
                ),
                mapOf(
                    "eventListeners.versions.version" to "-1",
                ),
            ),
        )),
)
```

## Structure

**TypeScript**

**query with all params **

```typescript
let query = await g.sys.db.query({
    instance: "INSTANCE_NAME", database: 'DB_NAME', collection: "COLLECTION_NAME",
    find: {
        "COLUMN_NAME": "VALUE"
    },
    limit: 10,
    select: "COMMA_SEPARATED_COLUMN_NAMES",
    deep: [
        {
            s_key: "SOURCE_COLLECTION_COLUMN_NAME",
            t_instance: "TARGET_INSTANCE_NAME",
            t_db: "TARGET_DATABASE_NAME",
            t_col: "TARGET_COLLECTION_NAME",
            t_key: "TARGET_COLLECTION_COLUMN_NAME",
            find: {
                "COLUMN_NAME": "COLUMN_VALUE"
            },
            isMultiple: true,
            limit: 10,
            select: "COMMA_SEPARATED_COLUMN_NAMES",
            skip: 2,
            sort: "COLUMN_NAME",
        }
    ],
    skip: 1,
    sort: "COLUMN_NAME",
    groupBy: "COLUMN_NAME",
    getTotalCount: true,
    headers: {
        "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        "x-am-response-object-type": "make_flat", // no_action | make_flat
        "x-am-meta": "true", // true, false
        "x-am-internationalization": "USER_I18N_ID",
        "x-am-run-in-sandbox": "2",
        "x-am-content-type-response": "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        "x-am-cache-control": "reset_cache", // no_action | reset_cache
        "x-am-get-encrypted-data": "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
        "x-am-sandbox-timeout": "13000",
        "x-no-compression": "true", // true | false
        "x-am-encrypted-payload": "true", // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        "x-am-tenant-username": "TENANT_USERNAME", // ex: acme
        // Authorization headers
        "x-am-authorization": "AUTHORIZATION_TOKEN",
        "x-am-user-authorization": "API_USER_TOKEN",
        "x-aws-authorization": "AWS_TOKEN",
        "x-google-authorization": "GOOGLE_TOKEN",
        "x-azure-authorization": "AZURE_TOKEN",
    },
}, true);
```

**Python**

**query with all params **

```python
query = await g.sys.db.full.query(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    find={
        'COLUMN_NAME': 'VALUE',
    },
    limit=10,
    select='COMMA_SEPARATED_COLUMN_NAMES',
    deep=[
        DeepItem(
            'SOURCE_COLLECTION_COLUMN_NAME',
            t_instance='TARGET_INSTANCE_NAME',
            t_db='TARGET_DATABASE_NAME',
            t_col='TARGET_COLLECTION_NAME',
            t_key='TARGET_COLLECTION_COLUMN_NAME',
            find={
                'COLUMN_NAME': 'COLUMN_VALUE',
            },
            is_multiple=True,
            limit=10,
            select='COMMA_SEPARATED_COLUMN_NAMES',
            skip=2,
            sort='COLUMN_NAME',
        ),
    ],
    skip=1,
    sort='COLUMN_NAME',
    group_by='COLUMN_NAME',
    get_total_count=True,
    headers={
        'x-am-response-case': 'capitalCase',  # noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        'x-am-response-object-type': 'make_flat',  # no_action | make_flat
        'x-am-meta': 'true',  # true, false
        'x-am-internationalization': 'USER_I18N_ID',
        'x-am-run-in-sandbox': '2',
        'x-am-content-type-response': 'text/xml',  # application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        'x-am-cache-control': 'reset_cache',  # no_action | reset_cache
        'x-am-get-encrypted-data': 'get_only_encryption',  # no_encryption | get_only_encryption | get_data_and_encryption
        'x-am-sandbox-timeout': '13000',
        'x-no-compression': 'true',  # true | false
        'x-am-encrypted-payload': 'true',  # user will send 'true', when payload is encrypted for transfer
        # Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        'x-am-tenant-username': 'TENANT_USERNAME',  # ex: acme
        # Authorization headers
        'x-am-authorization': 'AUTHORIZATION_TOKEN',
        'x-am-user-authorization': 'API_USER_TOKEN',
        'x-aws-authorization': 'AWS_TOKEN',
        'x-google-authorization': 'GOOGLE_TOKEN',
        'x-azure-authorization': 'AZURE_TOKEN',
    },
)
```

**PHP**

**query with all params **

```php
$query = $g->sys->db->full->query(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    find: [
        'COLUMN_NAME' => 'VALUE',
    ],
    limit: 10,
    select: 'COMMA_SEPARATED_COLUMN_NAMES',
    deep: [
        new DeepItem(
            'SOURCE_COLLECTION_COLUMN_NAME',
            tInstance: 'TARGET_INSTANCE_NAME',
            tDb: 'TARGET_DATABASE_NAME',
            tCol: 'TARGET_COLLECTION_NAME',
            tKey: 'TARGET_COLLECTION_COLUMN_NAME',
            find: [
                'COLUMN_NAME' => 'COLUMN_VALUE',
            ],
            isMultiple: true,
            limit: 10,
            select: 'COMMA_SEPARATED_COLUMN_NAMES',
            skip: 2,
            sort: 'COLUMN_NAME',
        ),
    ],
    skip: 1,
    sort: 'COLUMN_NAME',
    groupBy: 'COLUMN_NAME',
    getTotalCount: true,
    headers: [
        'x-am-response-case' => 'capitalCase', // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        'x-am-response-object-type' => 'make_flat', // no_action | make_flat
        'x-am-meta' => 'true', // true, false
        'x-am-internationalization' => 'USER_I18N_ID',
        'x-am-run-in-sandbox' => '2',
        'x-am-content-type-response' => 'text/xml', // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        'x-am-cache-control' => 'reset_cache', // no_action | reset_cache
        'x-am-get-encrypted-data' => 'get_only_encryption', // no_encryption | get_only_encryption | get_data_and_encryption
        'x-am-sandbox-timeout' => '13000',
        'x-no-compression' => 'true', // true | false
        'x-am-encrypted-payload' => 'true', // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        'x-am-tenant-username' => 'TENANT_USERNAME', // ex: acme
        // Authorization headers
        'x-am-authorization' => 'AUTHORIZATION_TOKEN',
        'x-am-user-authorization' => 'API_USER_TOKEN',
        'x-aws-authorization' => 'AWS_TOKEN',
        'x-google-authorization' => 'GOOGLE_TOKEN',
        'x-azure-authorization' => 'AZURE_TOKEN',
    ],
);
```

**C#**

**query with all params **

```csharp
var query = await g.Sys.Db.Full.Query(new Query("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
{
    Find = new JsonObject
    {
        ["COLUMN_NAME"] = "VALUE",
    },
    Limit = 10,
    Select = "COMMA_SEPARATED_COLUMN_NAMES",
    Deep = new[]
    {
        new DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
        {
            TInstance = "TARGET_INSTANCE_NAME",
            TDb = "TARGET_DATABASE_NAME",
            TCol = "TARGET_COLLECTION_NAME",
            TKey = "TARGET_COLLECTION_COLUMN_NAME",
            Find = new JsonObject
            {
                ["COLUMN_NAME"] = "COLUMN_VALUE",
            },
            IsMultiple = true,
            Limit = 10,
            Select = "COMMA_SEPARATED_COLUMN_NAMES",
            Skip = 2,
            Sort = "COLUMN_NAME",
        },
    },
    Skip = 1,
    Sort = "COLUMN_NAME",
    GroupBy = "COLUMN_NAME",
    GetTotalCount = true,
    Headers = new JsonObject
    {
        ["x-am-response-case"] = "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        ["x-am-response-object-type"] = "make_flat", // no_action | make_flat
        ["x-am-meta"] = "true", // true, false
        ["x-am-internationalization"] = "USER_I18N_ID",
        ["x-am-run-in-sandbox"] = "2",
        ["x-am-content-type-response"] = "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        ["x-am-cache-control"] = "reset_cache", // no_action | reset_cache
        ["x-am-get-encrypted-data"] = "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
        ["x-am-sandbox-timeout"] = "13000",
        ["x-no-compression"] = "true", // true | false
        ["x-am-encrypted-payload"] = "true", // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        ["x-am-tenant-username"] = "TENANT_USERNAME", // ex: acme
        // Authorization headers
        ["x-am-authorization"] = "AUTHORIZATION_TOKEN",
        ["x-am-user-authorization"] = "API_USER_TOKEN",
        ["x-aws-authorization"] = "AWS_TOKEN",
        ["x-google-authorization"] = "GOOGLE_TOKEN",
        ["x-azure-authorization"] = "AZURE_TOKEN",
    },
});
```

**Go**

**query with all params **

```go
query, err := g.Sys.Db.Full.Query(am.Query{
	Instance: "INSTANCE_NAME", Database: "DB_NAME", Collection: "COLLECTION_NAME",
	Find: am.M{
		"COLUMN_NAME": "VALUE",
	},
	Limit:  10,
	Select: "COMMA_SEPARATED_COLUMN_NAMES",
	Deep: []am.DeepItem{
		{
			SKey:      "SOURCE_COLLECTION_COLUMN_NAME",
			TInstance: "TARGET_INSTANCE_NAME",
			TDb:       "TARGET_DATABASE_NAME",
			TCol:      "TARGET_COLLECTION_NAME",
			TKey:      "TARGET_COLLECTION_COLUMN_NAME",
			Find: am.M{
				"COLUMN_NAME": "COLUMN_VALUE",
			},
			IsMultiple: true,
			Limit:      10,
			Select:     "COMMA_SEPARATED_COLUMN_NAMES",
			Skip:       2,
			Sort:       "COLUMN_NAME",
		},
	},
	Skip:          1,
	Sort:          "COLUMN_NAME",
	GroupBy:       "COLUMN_NAME",
	GetTotalCount: true,
	Headers: am.M{
		"x-am-response-case":         "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
		"x-am-response-object-type":  "make_flat",   // no_action | make_flat
		"x-am-meta":                  "true",        // true, false
		"x-am-internationalization":  "USER_I18N_ID",
		"x-am-run-in-sandbox":        "2",
		"x-am-content-type-response": "text/xml",            // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
		"x-am-cache-control":         "reset_cache",         // no_action | reset_cache
		"x-am-get-encrypted-data":    "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
		"x-am-sandbox-timeout":       "13000",
		"x-no-compression":           "true", // true | false
		"x-am-encrypted-payload":     "true", // user will send 'true', when payload is encrypted for transfer
		// Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
		"x-am-tenant-username": "TENANT_USERNAME", // ex: acme
		// Authorization headers
		"x-am-authorization":      "AUTHORIZATION_TOKEN",
		"x-am-user-authorization": "API_USER_TOKEN",
		"x-aws-authorization":     "AWS_TOKEN",
		"x-google-authorization":  "GOOGLE_TOKEN",
		"x-azure-authorization":   "AZURE_TOKEN",
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**query with all params **

```rust
let query = g.sys.db.full.query(
    Query::new("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
        .find(json!({
            "COLUMN_NAME": "VALUE",
        }))
        .limit(10)
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .deep(vec![
            DeepItem::new("SOURCE_COLLECTION_COLUMN_NAME")
                .t_instance("TARGET_INSTANCE_NAME")
                .t_db("TARGET_DATABASE_NAME")
                .t_col("TARGET_COLLECTION_NAME")
                .t_key("TARGET_COLLECTION_COLUMN_NAME")
                .find(json!({
                    "COLUMN_NAME": "COLUMN_VALUE",
                }))
                .is_multiple(true)
                .limit(10)
                .select("COMMA_SEPARATED_COLUMN_NAMES")
                .skip(2)
                .sort("COLUMN_NAME"),
        ])
        .skip(1)
        .sort("COLUMN_NAME")
        .group_by("COLUMN_NAME")
        .get_total_count(true)
        .headers(json!({
            "x-am-response-case": "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
            "x-am-response-object-type": "make_flat", // no_action | make_flat
            "x-am-meta": "true", // true, false
            "x-am-internationalization": "USER_I18N_ID",
            "x-am-run-in-sandbox": "2",
            "x-am-content-type-response": "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
            "x-am-cache-control": "reset_cache", // no_action | reset_cache
            "x-am-get-encrypted-data": "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
            "x-am-sandbox-timeout": "13000",
            "x-no-compression": "true", // true | false
            "x-am-encrypted-payload": "true", // user will send 'true', when payload is encrypted for transfer
            // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
            "x-am-tenant-username": "TENANT_USERNAME", // ex: acme
            // Authorization headers
            "x-am-authorization": "AUTHORIZATION_TOKEN",
            "x-am-user-authorization": "API_USER_TOKEN",
            "x-aws-authorization": "AWS_TOKEN",
            "x-google-authorization": "GOOGLE_TOKEN",
            "x-azure-authorization": "AZURE_TOKEN",
        })),
)?;
```

**Java**

**query with all params **

```java
var query = g.sys.db.full.query(new Query("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
    .find(Map.of(
        "COLUMN_NAME", "VALUE"
    ))
    .limit(10)
    .select("COMMA_SEPARATED_COLUMN_NAMES")
    .deep(List.of(
        new DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
            .tInstance("TARGET_INSTANCE_NAME")
            .tDb("TARGET_DATABASE_NAME")
            .tCol("TARGET_COLLECTION_NAME")
            .tKey("TARGET_COLLECTION_COLUMN_NAME")
            .find(Map.of(
                "COLUMN_NAME", "COLUMN_VALUE"
            ))
            .isMultiple(true)
            .limit(10)
            .select("COMMA_SEPARATED_COLUMN_NAMES")
            .skip(2)
            .sort("COLUMN_NAME")
    ))
    .skip(1)
    .sort("COLUMN_NAME")
    .groupBy("COLUMN_NAME")
    .getTotalCount(true)
    .headers(JsonObject.of(
        "x-am-response-case", "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
        "x-am-response-object-type", "make_flat", // no_action | make_flat
        "x-am-meta", "true", // true, false
        "x-am-internationalization", "USER_I18N_ID",
        "x-am-run-in-sandbox", "2",
        "x-am-content-type-response", "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
        "x-am-cache-control", "reset_cache", // no_action | reset_cache
        "x-am-get-encrypted-data", "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
        "x-am-sandbox-timeout", "13000",
        "x-no-compression", "true", // true | false
        "x-am-encrypted-payload", "true", // user will send 'true', when payload is encrypted for transfer
        // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
        "x-am-tenant-username", "TENANT_USERNAME", // ex: acme
        // Authorization headers
        "x-am-authorization", "AUTHORIZATION_TOKEN",
        "x-am-user-authorization", "API_USER_TOKEN",
        "x-aws-authorization", "AWS_TOKEN",
        "x-google-authorization", "GOOGLE_TOKEN",
        "x-azure-authorization", "AZURE_TOKEN"
    )));
```

**Kotlin**

**query with all params **

```kotlin
val query = g.sys.db.full.query(
    Query("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
        .find(mapOf(
            "COLUMN_NAME" to "VALUE",
        ))
        .limit(10)
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .deep(listOf(
            DeepItem("SOURCE_COLLECTION_COLUMN_NAME")
                .tInstance("TARGET_INSTANCE_NAME")
                .tDb("TARGET_DATABASE_NAME")
                .tCol("TARGET_COLLECTION_NAME")
                .tKey("TARGET_COLLECTION_COLUMN_NAME")
                .find(mapOf(
                    "COLUMN_NAME" to "COLUMN_VALUE",
                ))
                .isMultiple(true)
                .limit(10)
                .select("COMMA_SEPARATED_COLUMN_NAMES")
                .skip(2)
                .sort("COLUMN_NAME"),
        ))
        .skip(1)
        .sort("COLUMN_NAME")
        .groupBy("COLUMN_NAME")
        .getTotalCount(true)
        .headers(mapOf(
            "x-am-response-case" to "capitalCase", // noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
            "x-am-response-object-type" to "make_flat", // no_action | make_flat
            "x-am-meta" to "true", // true, false
            "x-am-internationalization" to "USER_I18N_ID",
            "x-am-run-in-sandbox" to "2",
            "x-am-content-type-response" to "text/xml", // application/json | text/xml | text/yaml | text/plain | text/html | application/octet-stream
            "x-am-cache-control" to "reset_cache", // no_action | reset_cache
            "x-am-get-encrypted-data" to "get_only_encryption", // no_encryption | get_only_encryption | get_data_and_encryption
            "x-am-sandbox-timeout" to "13000",
            "x-no-compression" to "true", // true | false
            "x-am-encrypted-payload" to "true", // user will send 'true', when payload is encrypted for transfer
            // Multi-tenant : the tenant of the request, each instance finds it in its own tenants table
            "x-am-tenant-username" to "TENANT_USERNAME", // ex: acme
            // Authorization headers
            "x-am-authorization" to "AUTHORIZATION_TOKEN",
            "x-am-user-authorization" to "API_USER_TOKEN",
            "x-aws-authorization" to "AWS_TOKEN",
            "x-google-authorization" to "GOOGLE_TOKEN",
            "x-azure-authorization" to "AZURE_TOKEN",
        )),
)
```

## Multi-tenant
- `instance: "crm::acme"` works on the database of the tenant `acme` of the [multi-tenant](https://docs.apimaker.dev/v4/docs/features/multi-tenant.html) instance `crm`.
- With `instance: "crm"`, the call works on the database of the tenant of the request: a custom API called with the [x-am-tenant-username](https://docs.apimaker.dev/v4/docs/apis-all/header/requestHeader.html#x-am-tenant-username) header passes it on to the APIs it calls. A request without a tenant works on the structure database.

**TypeScript**

**Query the customers of the tenant acme**

```typescript
let query = await g.sys.db.query({
    instance: "crm::acme", database: "crm", collection: "customers",
    find: {
        "first_name": "Bob"
    },
    sort: "customer_id",
    limit: 10
});
```

**Python**

**Query the customers of the tenant acme**

```python
query = await g.sys.db.query(
    'crm::acme', 'crm', 'customers',
    find={
        'first_name': 'Bob',
    },
    sort='customer_id',
    limit=10,
)
```

**PHP**

**Query the customers of the tenant acme**

```php
$query = $g->sys->db->query(
    'crm::acme', 'crm', 'customers',
    find: [
        'first_name' => 'Bob',
    ],
    sort: 'customer_id',
    limit: 10,
);
```

**C#**

**Query the customers of the tenant acme**

```csharp
var query = await g.Sys.Db.Query(new Query("crm::acme", "crm", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "Bob",
    },
    Sort = "customer_id",
    Limit = 10,
});
```

**Go**

**Query the customers of the tenant acme**

```go
query, err := g.Sys.Db.Query(am.Query{
	Instance: "crm::acme", Database: "crm", Collection: "customers",
	Find: am.M{
		"first_name": "Bob",
	},
	Sort:  "customer_id",
	Limit: 10,
})
if err != nil {
	return nil, err
}
```

**Rust**

**Query the customers of the tenant acme**

```rust
let query = g.sys.db.query(
    Query::new("crm::acme", "crm", "customers")
        .find(json!({
            "first_name": "Bob",
        }))
        .sort("customer_id")
        .limit(10),
)?;
```

**Java**

**Query the customers of the tenant acme**

```java
var query = g.sys.db.query(new Query("crm::acme", "crm", "customers")
    .find(Map.of(
        "first_name", "Bob"
    ))
    .sort("customer_id")
    .limit(10));
```

**Kotlin**

**Query the customers of the tenant acme**

```kotlin
val query = g.sys.db.query(
    Query("crm::acme", "crm", "customers")
        .find(mapOf(
            "first_name" to "Bob",
        ))
        .sort("customer_id")
        .limit(10),
)
```

## Without a schema

`g.sys.db.gen.queryGen` takes the same arguments and calls the [query for get data generated API](https://docs.apimaker.dev/v4/docs/apis-all/schema-apis/auto-generated-schema-based-query-for-get-data-api.html#without-a-schema) : no schema, so the data is read and written as it is in the table, without the conversions, validations and defaults of the schema.

| Language | The call |
|---|---|
| TypeScript | `g.sys.db.gen.queryGen(…)` |
| Python | `g.sys.db.gen.query_gen(…)` |
| PHP | `$g->sys->db->gen->queryGen(…)` |
| C#, Go | `g.Sys.Db.Gen.QueryGen(…)` |
| Rust | `g.sys.db.query_gen(Query::new(…))` |
| Java, Kotlin | `g.sys.db.gen.queryGen(…)` |
