Skip to main content

list

The list method is used to get all data in the corresponding Database Element.

async function list(): Promise<Array<Entry<T>>>;

Reference​

Overview​

You can use the list method to retrieve all data stored in the Database Element.

import { User } from "#elements";

...

await User.list();
...

Returns​

The return value is an array of data objects formed by merging the fields defined in the Database Element and the key.

Caveats​

  • The data returned by calling list filters out fields not defined in the Database Element.

Examples​

get list of data from Database Element​

The User Database Element defines two fields, name 和 actived. Here's an example of getting all data from the Database Element in a Function Element.

import { User } from "#elements";

export default async function () {
return await User.list();
}

return value:

[
{
"key": "user-1",
"name": "user-1",
"actived": true
},
{
"key": "user-2",
"name": "user-2",
"actived": false
}
]