# Get All

> Retrieve all records from a specified collection in your database using API Maker's `g.sys.db.getAll` method.

Source: https://docs.apimaker.dev/v4/examples/sys/db/getAll.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`.

`g.sys.db.getAll` calls the [get all schema API](https://docs.apimaker.dev/v4/docs/apis-all/schema-apis/auto-generated-schema-based-get-all-api.html) of any table from your code, with the same headers and query parameters as over HTTP. It returns the data. The whole envelope (`success`, `statusCode`, `data`, `totalCount`, `errors`…) comes back when `true` is passed as the second argument in TypeScript, and through `full` in the other languages : `g.sys.db.full` (`g.Sys.Db.Full` in C# and Go, `$g->sys->db->full` in PHP).

## Get all data

**TypeScript**

**Get all data from table 'customers'**

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

**Python**

**Get all data from table 'customers'**

```python
get_all = await g.sys.db.get_all(
    'mysql_8', 'inventory', 'customers',
)
```

**PHP**

**Get all data from table 'customers'**

```php
$getAll = $g->sys->db->getAll(
    'mysql_8', 'inventory', 'customers',
);
```

**C#**

**Get all data from table 'customers'**

```csharp
var getAll = await g.Sys.Db.GetAll(new GetAll("mysql_8", "inventory", "customers"));
```

**Go**

**Get all data from table 'customers'**

```go
getAll, err := g.Sys.Db.GetAll(am.GetAll{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
})
if err != nil {
	return nil, err
}
```

**Rust**

**Get all data from table 'customers'**

```rust
let get_all = g.sys.db.get_all(GetAll::new("mysql_8", "inventory", "customers"))?;
```

**Java**

**Get all data from table 'customers'**

```java
var getAll = g.sys.db.getAll(new GetAll("mysql_8", "inventory", "customers"));
```

**Kotlin**

**Get all data from table 'customers'**

```kotlin
val getAll = g.sys.db.getAll(GetAll("mysql_8", "inventory", "customers"))
```

## With header

**TypeScript**

**Get all with header**

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

**Python**

**Get all with header**

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

**PHP**

**Get all with header**

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

**C#**

**Get all with header**

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

**Go**

**Get all with header**

```go
getAll, err := g.Sys.Db.GetAll(am.GetAll{
	Instance: "mysql_8", Database: "inventory", Collection: "customers",
	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**

**Get all with header**

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

**Java**

**Get all with header**

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

**Kotlin**

**Get all with header**

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

## With queryParams

**TypeScript**

**Get all with queryParams**

```typescript
let getAll = await g.sys.db.getAll({
    instance: "mysql_8", database: "inventory", collection: "customers",
    queryParams: {
        find: {
            first_name: 'James',
        },
    },
}, true);
```

**Python**

**Get all with queryParams**

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

**PHP**

**Get all with queryParams**

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

**C#**

**Get all with queryParams**

```csharp
var getAll = await g.Sys.Db.Full.GetAll(new GetAll("mysql_8", "inventory", "customers")
{
    Find = new JsonObject
    {
        ["first_name"] = "James",
    },
});
```

**Go**

**Get all with queryParams**

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

**Rust**

**Get all with queryParams**

```rust
let get_all = g.sys.db.full.get_all(
    GetAll::new("mysql_8", "inventory", "customers")
        .find(json!({
            "first_name": "James",
        })),
)?;
```

**Java**

**Get all with queryParams**

```java
var getAll = g.sys.db.full.getAll(new GetAll("mysql_8", "inventory", "customers")
    .find(Map.of(
        "first_name", "James"
    )));
```

**Kotlin**

**Get all with queryParams**

```kotlin
val getAll = g.sys.db.full.getAll(
    GetAll("mysql_8", "inventory", "customers")
        .find(mapOf(
            "first_name" to "James",
        )),
)
```

## Every header and query param

**TypeScript**

**Structure of get all schema API**

```typescript
let getAll = await g.sys.db.getAll({
    instance: "INSTANCE_NAME", database: 'DB_NAME', collection: "COLLECTION_NAME",
    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",
    },
    queryParams: {
        find: {
            "COLUMN_NAME": "COLUMN_VALUE"
        },
        skip: 1,
        limit: 5,
        sort: "COLUMN_NAME",
        select: "COMMA_SEPARATED_COLUMN_NAMES",
        getTotalCount: true,
        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",
                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",
                    }
                ]
            }
        ]
    },
}, true);
```

**Python**

**Structure of get all schema API**

```python
get_all = await g.sys.db.full.get_all(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    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',
    },
    find={
        'COLUMN_NAME': 'COLUMN_VALUE',
    },
    skip=1,
    limit=5,
    sort='COLUMN_NAME',
    select='COMMA_SEPARATED_COLUMN_NAMES',
    get_total_count=True,
    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',
            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',
                ),
            ],
        ),
    ],
)
```

**PHP**

**Structure of get all schema API**

```php
$getAll = $g->sys->db->full->getAll(
    'INSTANCE_NAME', 'DB_NAME', 'COLLECTION_NAME',
    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',
    ],
    find: [
        'COLUMN_NAME' => 'COLUMN_VALUE',
    ],
    skip: 1,
    limit: 5,
    sort: 'COLUMN_NAME',
    select: 'COMMA_SEPARATED_COLUMN_NAMES',
    getTotalCount: true,
    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',
            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',
                ),
            ],
        ),
    ],
);
```

**C#**

**Structure of get all schema API**

```csharp
var getAll = await g.Sys.Db.Full.GetAll(new GetAll("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
{
    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",
    },
    Find = new JsonObject
    {
        ["COLUMN_NAME"] = "COLUMN_VALUE",
    },
    Skip = 1,
    Limit = 5,
    Sort = "COLUMN_NAME",
    Select = "COMMA_SEPARATED_COLUMN_NAMES",
    GetTotalCount = true,
    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",
            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",
                },
            },
        },
    },
});
```

**Go**

**Structure of get all schema API**

```go
getAll, err := g.Sys.Db.Full.GetAll(am.GetAll{
	Instance: "INSTANCE_NAME", Database: "DB_NAME", Collection: "COLLECTION_NAME",
	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",
	},
	Find: am.M{
		"COLUMN_NAME": "COLUMN_VALUE",
	},
	Skip:          1,
	Limit:         5,
	Sort:          "COLUMN_NAME",
	Select:        "COMMA_SEPARATED_COLUMN_NAMES",
	GetTotalCount: true,
	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",
			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",
				},
			},
		},
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**Structure of get all schema API**

```rust
let get_all = g.sys.db.full.get_all(
    GetAll::new("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
        .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",
        }))
        .find(json!({
            "COLUMN_NAME": "COLUMN_VALUE",
        }))
        .skip(1)
        .limit(5)
        .sort("COLUMN_NAME")
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .get_total_count(true)
        .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")
                .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"),
                ]),
        ]),
)?;
```

**Java**

**Structure of get all schema API**

```java
var getAll = g.sys.db.full.getAll(new GetAll("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
    .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"
    ))
    .find(Map.of(
        "COLUMN_NAME", "COLUMN_VALUE"
    ))
    .skip(1)
    .limit(5)
    .sort("COLUMN_NAME")
    .select("COMMA_SEPARATED_COLUMN_NAMES")
    .getTotalCount(true)
    .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")
            .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")
            ))
    )));
```

**Kotlin**

**Structure of get all schema API**

```kotlin
val getAll = g.sys.db.full.getAll(
    GetAll("INSTANCE_NAME", "DB_NAME", "COLLECTION_NAME")
        .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",
        ))
        .find(mapOf(
            "COLUMN_NAME" to "COLUMN_VALUE",
        ))
        .skip(1)
        .limit(5)
        .sort("COLUMN_NAME")
        .select("COMMA_SEPARATED_COLUMN_NAMES")
        .getTotalCount(true)
        .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")
                .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"),
                )),
        )),
)
```

## 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**

**Get all customers of the tenant acme**

```typescript
let getAll = await g.sys.db.getAll({
    instance: "crm::acme", database: "crm", collection: "customers",
    queryParams: {
        sort: "customer_id"
    }
});
```

**Python**

**Get all customers of the tenant acme**

```python
get_all = await g.sys.db.get_all(
    'crm::acme', 'crm', 'customers',
    sort='customer_id',
)
```

**PHP**

**Get all customers of the tenant acme**

```php
$getAll = $g->sys->db->getAll(
    'crm::acme', 'crm', 'customers',
    sort: 'customer_id',
);
```

**C#**

**Get all customers of the tenant acme**

```csharp
var getAll = await g.Sys.Db.GetAll(new GetAll("crm::acme", "crm", "customers")
{
    Sort = "customer_id",
});
```

**Go**

**Get all customers of the tenant acme**

```go
getAll, err := g.Sys.Db.GetAll(am.GetAll{
	Instance: "crm::acme", Database: "crm", Collection: "customers",
	Sort: "customer_id",
})
if err != nil {
	return nil, err
}
```

**Rust**

**Get all customers of the tenant acme**

```rust
let get_all = g.sys.db.get_all(
    GetAll::new("crm::acme", "crm", "customers")
        .sort("customer_id"),
)?;
```

**Java**

**Get all customers of the tenant acme**

```java
var getAll = g.sys.db.getAll(new GetAll("crm::acme", "crm", "customers")
    .sort("customer_id"));
```

**Kotlin**

**Get all customers of the tenant acme**

```kotlin
val getAll = g.sys.db.getAll(
    GetAll("crm::acme", "crm", "customers")
        .sort("customer_id"),
)
```

**TypeScript**

**Get all customers of the tenant globex, named with the header of the call**

```typescript
let getAll = await g.sys.db.getAll({
    instance: "crm", database: "crm", collection: "customers",
    headers: {
        "x-am-tenant-username": "globex"
    }
});
```

**Python**

**Get all customers of the tenant globex, named with the header of the call**

```python
get_all = await g.sys.db.get_all(
    'crm', 'crm', 'customers',
    headers={
        'x-am-tenant-username': 'globex',
    },
)
```

**PHP**

**Get all customers of the tenant globex, named with the header of the call**

```php
$getAll = $g->sys->db->getAll(
    'crm', 'crm', 'customers',
    headers: [
        'x-am-tenant-username' => 'globex',
    ],
);
```

**C#**

**Get all customers of the tenant globex, named with the header of the call**

```csharp
var getAll = await g.Sys.Db.GetAll(new GetAll("crm", "crm", "customers")
{
    Headers = new JsonObject
    {
        ["x-am-tenant-username"] = "globex",
    },
});
```

**Go**

**Get all customers of the tenant globex, named with the header of the call**

```go
getAll, err := g.Sys.Db.GetAll(am.GetAll{
	Instance: "crm", Database: "crm", Collection: "customers",
	Headers: am.M{
		"x-am-tenant-username": "globex",
	},
})
if err != nil {
	return nil, err
}
```

**Rust**

**Get all customers of the tenant globex, named with the header of the call**

```rust
let get_all = g.sys.db.get_all(
    GetAll::new("crm", "crm", "customers")
        .headers(json!({
            "x-am-tenant-username": "globex",
        })),
)?;
```

**Java**

**Get all customers of the tenant globex, named with the header of the call**

```java
var getAll = g.sys.db.getAll(new GetAll("crm", "crm", "customers")
    .headers(Map.of(
        "x-am-tenant-username", "globex"
    )));
```

**Kotlin**

**Get all customers of the tenant globex, named with the header of the call**

```kotlin
val getAll = g.sys.db.getAll(
    GetAll("crm", "crm", "customers")
        .headers(mapOf(
            "x-am-tenant-username" to "globex",
        )),
)
```

## Without a schema

`g.sys.db.gen.getAllGen` takes the same arguments and calls the [get all generated API](https://docs.apimaker.dev/v4/docs/apis-all/schema-apis/auto-generated-schema-based-get-all-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.getAllGen(…)` |
| Python | `g.sys.db.gen.get_all_gen(…)` |
| PHP | `$g->sys->db->gen->getAllGen(…)` |
| C#, Go | `g.Sys.Db.Gen.GetAllGen(…)` |
| Rust | `g.sys.db.get_all_gen(GetAll::new(…))` |
| Java, Kotlin | `g.sys.db.gen.getAllGen(…)` |

## Related

- [Get all API](https://docs.apimaker.dev/v4/docs/apis-all/schema-apis/auto-generated-schema-based-get-all-api.html) · [Generated API from code](https://docs.apimaker.dev/v4/examples/sys/db/getAll.html#without-a-schema) · [The global object g](https://docs.apimaker.dev/v4/docs/pre-defined-terms/global-object-g.html)
