The .NET SDK can load a SurrealQL script into the database it is connected to, and can write the database out as a SurrealQL script.
| Method | Description |
|---|---|
db.Import() | Imports data into a SurrealDB database |
db.Export() | Exports the database as a SurrealQL script |
.Import()
Imports data into a SurrealDB database. To use this method, you need to be connected to a SurrealDB instance that is version >= 2.0.0.
Method Syntax
await db.Import(string)Arguments
Arguments | Description |
|---|---|
input | The SurrealQL script used to import data in the database. |
cancellationToken | The cancellationToken enables graceful cancellation of asynchronous operations. |
Example usage
string input =
"""
DEFINE TABLE foo SCHEMALESS;
DEFINE TABLE bar SCHEMALESS;
CREATE foo:1 CONTENT { hello: "world" };
CREATE bar:1 CONTENT { hello: "world" };
DEFINE FUNCTION fn::foo() -> string {
RETURN "bar";
};
""";
await db.Import(input); .Export()
Export the database as a SurrealQL script. To use this method, you need to be connected to a SurrealDB instance that is version >= 2.1.0.
Method Syntax
await db.Export(options)Arguments
Arguments | Description |
|---|---|
options | Export configuration options. |
cancellationToken | The cancellationToken enables graceful cancellation of asynchronous operations. |
Example usage
Only exporting db functions in a schema variable
var options = new ExportOptions
{
Users = false,
Accesses = false,
Params = false,
Functions = true,
Users = false,
Versions = false,
Tables = false,
Records = false,
};
string schema = await db.Export(options);