Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document import and Export C# methods #1243

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/content/doc-sdk-dotnet/methods/export.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
sidebar_position: 1
sidebar_label: Export
title: .NET | SDK | Methods | Export
description: The .NET SDK for SurrealDB enables simple and advanced querying of a remote or embedded database.
---

import Label from "@components/shared/Label.astro";

# `.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`.

```csharp title="Method Syntax"
await db.Export(options)
```

### Arguments

<table>
<thead>
<tr>
<th colspan="2" scope="col">Arguments</th>
<th colspan="2" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" scope="row" data-label="Arguments">
<code>options</code>
<Label label="optional" />
</td>
<td colspan="2" scope="row" data-label="Description">
Export configuration options.
</td>
</tr>
<tr>
<td colspan="2" scope="row" data-label="Arguments">
<code>cancellationToken</code>
<Label label="optional" />
</td>
<td colspan="2" scope="row" data-label="Description">
The cancellationToken enables graceful cancellation of asynchronous operations.
</td>
</tr>
</tbody>
</table>

### Example usage

```csharp title="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);
```

66 changes: 66 additions & 0 deletions src/content/doc-sdk-dotnet/methods/import.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
sidebar_position: 1
sidebar_label: Import
title: .NET | SDK | Methods | Import
description: The .NET SDK for SurrealDB enables simple and advanced querying of a remote or embedded database.
---

import Label from "@components/shared/Label.astro";

# `.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`.

```csharp title="Method Syntax"
await db.Import(string)
```

### Arguments

<table>
<thead>
<tr>
<th colspan="2" scope="col">Arguments</th>
<th colspan="2" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" scope="row" data-label="Arguments">
<code>input</code>
<Label label="required" />
</td>
<td colspan="2" scope="row" data-label="Description">
The SurrealQL script used to import data in the database.
</td>
</tr>
<tr>
<td colspan="2" scope="row" data-label="Arguments">
<code>cancellationToken</code>
<Label label="optional" />
</td>
<td colspan="2" scope="row" data-label="Description">
The cancellationToken enables graceful cancellation of asynchronous operations.
</td>
</tr>
</tbody>
</table>

### Example usage

```csharp
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() {
RETURN "bar";
};
""";

await db.Import(input);
```