Skip to content

Commit

Permalink
feat: add surrealdb apphost integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Odonno committed Sep 17, 2024
1 parent 296ef57 commit a697f81
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
18 changes: 18 additions & 0 deletions docs/database/includes/surrealdb-app-host.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
To model the SurrealDB resource in the app host, install the [Aspire.Hosting.SurrealDb](https://www.nuget.org/packages/Aspire.Hosting.SurrealDb) NuGet package in the [app host](xref:aspire/app-host) project.

### [.NET CLI](#tab/dotnet-cli)

```dotnetcli
dotnet add package Aspire.Hosting.SurrealDb
```

### [PackageReference](#tab/package-reference)

```xml
<PackageReference Include="Aspire.Hosting.SurrealDb"
Version="[SelectVersion]" />
```

---

In your app host project, register a SurrealDb database and consume the connection using the following methods:
47 changes: 47 additions & 0 deletions docs/database/surrealdb-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: .NET Aspire SurrealDB integration
description: This article describes the .NET Aspire SurrealDB integration.
ms.topic: how-to
ms.date: 09/17/2024
---

# .NET Aspire SurrealDB integration

<!-- TODO : intro & get started sections -->

## App host usage

[!INCLUDE [surrealdb-app-host](includes/surrealdb-app-host.md)]

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var surrealServer = builder.AddSurrealServer("surreal");
var surrealDb = mysql.AddDatabase("mydb", "ns", "db");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(surrealDb);
```

When you want to explicitly provide a root password, you can provide it as a parameter. Consider the following alternative example:

```csharp
var password = builder.AddParameter("password", secret: true);

var surrealServer = builder.AddSurrealServer("surreal", password);
var surrealDb = mysql.AddDatabase("mydb", "ns", "db");

var myService = builder.AddProject<Projects.MyService>()
.WithReference(surrealDb);
```

For more information, see [External parameters](../fundamentals/external-parameters.md).

<!-- TODO : configuration section -->

## See also

- [SurrealDB database](https://surrealdb.com/)
- [.NET SDK documentation for SurrealDB](https://surrealdb.com/docs/sdk/dotnet)
- [.NET Aspire integrations](../fundamentals/integrations-overview.md)
- [.NET Aspire GitHub repo](https://github.com/dotnet/aspire)
1 change: 1 addition & 0 deletions docs/fundamentals/integrations-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The following table lists the .NET Aspire integrations currently available for u
| [Seq](../logging/seq-integration.md) <br/> <img src="media/icons/Seq_logo.256x.png" alt="Seq logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Seq](https://www.nuget.org/packages/Aspire.Seq) | A library for logging to [Seq](https://datalust.co/seq). |
| [SQL Server Entity Framework Core](../database/sql-server-entity-framework-integration.md) <br/> <img src="media/icons/SQL_256x.png" alt="SQL logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Microsoft.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Aspire.Microsoft.EntityFrameworkCore.SqlServer) | A library for accessing [SQL Server databases using Entity Framework Core](/ef/core/providers/sql-server/). |
| [SQL Server](../database/sql-server-integration.md) <br/> <img src="media/icons/SQL_256x.png" alt="SQL logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Microsoft.Data.SqlClient](https://www.nuget.org/packages/Aspire.Microsoft.Data.SqlClient) | A library for accessing [SQL Server](/sql/sql-server/) databases. |
| [SurrealDB](../database/surrealdb-integration.md) <br/> <img src="media/icons/surrealdb.png" alt="SurrealDB logo." role="presentation" width="64" data-linktype="relative-path"> | [Aspire.Hosting.SurrealDb](https://www.nuget.org/packages/Aspire.Hosting.SurrealDb) | A library for accessing [SurrealDB](https://surrealdb.com/) databases. |
<!-- markdownlint-enable MD033 MD045 -->

For more information on working with .NET Aspire integrations in Visual Studio, see [Visual Studio tooling](setup-tooling.md#visual-studio-tooling).
Expand Down
Binary file added docs/fundamentals/media/icons/surrealdb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ items:
href: caching/stackexchange-redis-distributed-caching-integration.md?pivots=valkey
- name: Redis output caching (Valkey)
href: caching/stackexchange-redis-output-caching-integration.md?pivots=valkey
- name: Seq
displayName: seq,logging
href: logging/seq-integration.md
- name: SQL Server
items:
- name: SQL Database - EF Core
Expand All @@ -216,9 +219,9 @@ items:
- name: SQL Database
displayName: sql server,sql database
href: database/sql-server-integration.md
- name: Seq
displayName: seq,logging
href: logging/seq-integration.md
- name: SurrealDB
displayName: surrealdb,kv,document,graph,temporal
href: database/surrealdb-integration.md

- name: Deployment
items:
Expand Down

0 comments on commit a697f81

Please sign in to comment.