export()
Dumps the database contents to a file.
Note
Arguments
| Argument | Description |
|---|---|
resource
| The table name or a record ID to select. Will also accept a tuple of record name and ID. |
Example usage
The .export() method can be used to save the contents of a database to a file.
If an empty tuple is passed in for the file name, the .export() method will instead return an async stream of bytes.
The output for the above sample should look like the following.
Export configuration
The Export struct has a method called .with_config() that gives access to the configuration parameters for the export. These can be chained one after another inside a single line of code. The majority of these functions take a single bool:
.versions(): whether to include version information for the SurrealKV storage backend.accesses(): whether to includeDEFINE ACCESSstatements.analyzers(): whether to includeDEFINE ANALYZERstatements.functions(): whether to includeDEFINE FUNCTIONstatements.records(): whether to include the existing records in the database.params(): whether to includeDEFINE PARAMstatements.users(): whether to includeDEFINE USERstatements
.tables() takes a Vec of strings in addition to a boolean.
.tables(): a list of tables to export, as opposed to all of the tables in the database.
Example of export configuration: