-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add surrealdb apphost integration
- Loading branch information
Showing
5 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters