FileRef
The FileRef class represents a reference to a file stored in SurrealDB. File references are returned when querying records that contain file fields and provide access to file metadata such as the bucket, key, and media type.
Import:
Source: value/file-ref.ts
Properties
bucket
The name of the storage bucket containing the file.
Type: string
Example:
key
The unique key identifying the file within its bucket.
Type: string
Example:
Instance Methods
.toString()
Returns the string representation of the file reference.
Returns
string - The file reference as a string
.toJSON()
Serializes the file reference for JSON output.
Returns
string - The JSON-safe representation
.equals(other)
Compares this file reference with another for equality.
Parameters
| Parameter | Type | Description |
|---|---|---|
other | unknown | The value to compare against. |
Returns
boolean - True if both file references point to the same file
Example
Examples
Reading file references from records
Querying records with file fields
See Also
Value types - Overview of all value types
File uploads - Working with files in SurrealDB
Data Types - All custom data types