Skip to main content

getAsAny

The getAsAny method is used to get the stored data based on the key. Unlike get, getAsAny does not modify the query result according to the definition in the Database Element, and returns the data directly.

async function getAsAny(key: string): Promise<Entry<T>>;

Reference

Overview

You can use the getAsAny method to obtain the original data stored in the Database Element.

import { User } from "#elements";

...

await User.getAsAny("user-1");
...

Parameters

  • key: The unique identifier of the corresponding data.

Returns

The return value is a data object composed of the original data stored in the Database Element and the key.

Examples

get raw data from Database Element

The User Database Element defines two fields, name and actived. Here's an example of using the Database Element in a Function Element.

import { User } from "#elements";

export default async function () {
return await User.getAsAny("special-user")
}

return value:

{
"key": "special-user",
"name": "special-user",
"actived": true,
"age": 25
}