get()

Description

Get data from the database table

Request

Parameters

FieldRequiredData TypeDescription

options

Object

Options Object describing filtering, sorting, and other options

Options Object Parameters

FieldRequiredData TypeDescription

page

number

Page number to navigate to if the response is paginated

limit

number

Number of results per page if the response is paginated Default: 50

where

Array of Where Objects

sorted[how]

asc | desc

How to sort response results: ascending vs descending Must be used with sorted[param] parameter

sorted[param]

string

How to sort response results: what parameter to sort by

Must be used with sorted[param] parameter

includes

Array of string

An array of columns with one-to-one or one-to-many references that you would like to include in your response. For one-to-one reference the value will be returned as an object containing the includes in place of the reference value. For one-to-many reference the value will be returned as an array of objects containing the includes in place of the reference value.

Where Object Parameters

Note that UID cannot be used in the attribute field. If you want to get an item by UID, you can use the Get by UID method instead.

FieldRequiredData TypeDescription

attribute

string

Column name that you would like to query by

operator

< | > | == | != | <= | >= | array-contains | array-contains-any | in | not-in

An operator to perform the query

value

any

Value of the query

Examples

Get all

const products = await client.database().from('products').get()

Get all with filters

const products = await client.database().from('products').get({
    page: 1,
    limit: 10,
    where: [
        {
            attribute: "price",
            operator: ">",
            value: 10
        }
    ],
    "sorted[how]": "asc",
    "sorted[param]": "price",
    "includes": ["category"]
})

Response

Parameters

FieldData TypeDescription

data

Array of objects

Array of data objects

meta

Object

Object containing metadata

Database Object Parameters

FieldData TypeDescription

uid

string

UID of a database item

attributes

Object

Object containing all database item values

Metadata Parameters

FieldData TypeDescription

total

number

Total number of items in the database

page

number

Current page number

limit

number

Current limit per page

includesCount

number

Number of additional requests for the includes operations

Example

This is an example response to the Get all with filters request example above.

{
    "data": [
        {
            "uid": "iaijasdiadsi14in",
            "attributes": {
                "name": "T-Shirt",
                "price": 10,
                "category": {
                    "uid": "n10234b901489bwduih1dw91",
                    "name": "clothing"
                },
                "createdAt": "2022-08-22T16:04:49-04:00",
                "updatedAt": "2022-08-22T16:04:51-04:00"
            }
        }
    ],
    "meta": {
        "total": 1,
        "page": 1,
        "limit": 1,
        "includesCount": 1
    }
}

Last updated