getSchema()

Description

Get a table schema in JSON format.

Request

Parameters

FieldRequiredData TypeDescription

options

Object

Options Object describing filtering, sorting, and other options

Options Object Parameters

FieldRequiredData TypeDescription

table

string

Table name

database

default

Currently accepts only "default" value, but with multiple databases per project feature coming soon, it will be accepting the name of the database to extract the configs from. Default: "default"

format

default | formatted

Specify the format of how the database schema is to be returned.

  • formatted - will return a JSON with JS native datatypes and indication which columns are optional/required. Default: "default"

Example

const schema = await client.config().generateDataTypes({
    database: "default",
    table: "products",
    format: "formatted"
})

Response

An object containing the data schema of a given table.

Example

default

{
    "data": {
        "arrayOfInt": "Array<integer>?",
        "arrayOfFloats": "Array<float>?",
        "uid": "UID",
        "arrayOfStrings": "Array<string>?",
        "author": "String?",
        "image": "Storage?",
        "name": "String",
        "createdAt": "String?",
        "arrayOfBooleans": "Array<boolean>?",
        "updatedAt": "String?"
    }
}

formatted

{
    "data": {
        "uid": {
            "type": "string",
            "isOptional": false
        },
        "arrayOfBooleans": {
            "type": "boolean[]",
            "isOptional": true
        },
        "arrayOfFloats": {
            "type": "number[]",
            "isOptional": true
        },
        "author": {
            "type": "string",
            "isOptional": true
        },
        "updatedAt": {
            "type": "string",
            "isOptional": true
        },
        "createdAt": {
            "type": "string",
            "isOptional": true
        },
        "name": {
            "type": "string",
            "isOptional": false
        },
        "arrayOfStrings": {
            "type": "string[]",
            "isOptional": true
        },
        "image": {
            "type": "string",
            "isOptional": true
        },
        "arrayOfInt": {
            "type": "number[]",
            "isOptional": true
        }
    }
}

Last updated