SurrealDB.Configuration
1.0.4
This project is no longer supported, please use SurrealDb.Net instead.
See the version list below for details.
dotnet add package SurrealDB.Configuration --version 1.0.4
NuGet\Install-Package SurrealDB.Configuration -Version 1.0.4
<PackageReference Include="SurrealDB.Configuration" Version="1.0.4" />
paket add SurrealDB.Configuration --version 1.0.4
#r "nuget: SurrealDB.Configuration, 1.0.4"
// Install SurrealDB.Configuration as a Cake Addin #addin nuget:?package=SurrealDB.Configuration&version=1.0.4 // Install SurrealDB.Configuration as a Cake Tool #tool nuget:?package=SurrealDB.Configuration&version=1.0.4
<br /> <p align="center"> <img src="img/icon.png" alt="Logo" width="130" height="130"> </a> <h1 align="center">Surreal .NET</h1> <p align="center"> Database driver for SurrealDB available for REST and RPC sessions. </p>
<p align="center"> (unofficial) </p>
Table of contents
About
Surreal .NET is a database driver for SurrealDB. The connector can access the database via JSON-RPC as well as REST.
Primary NuGet Packages
Name | Description | Nuget |
---|---|---|
SurrealDB.Driver.Rpc |
Websocket RPC based database driver for SurrealDB | |
SurrealDB.Driver.Rest |
REST based database driver for SurrealDB. | |
SurrealDB.Extensions.Service |
Service integration into the ASP.NET Core ecosystem. |
Documentation
The API Documentation is available here
Quick-start
Firstly install SurrealDB on your system. See the installation instructions:
# Brew
brew install surrealdb/tap/surreal
# Linux
curl -sSf https://install.surrealdb.com | sh
# Windows - system
choco install surreal --pre
# Windows - user
iwr https://windows.surrealdb.com -useb | iex
While Surreal .NET can be registered as a ASP.NET Core service for usage in a web API, the library can also be included in a console app.
I highly recommend taking a looksie at the examples, but for now let's review a basic console app with the RPC library.
<PackageReference Include="SurrealDB.Driver.Rest" Version="1.0.3" />
using SurrealDB.Configuration;
using SurrealDB.Driver.Rpc;
using SurrealDB.Models;
// start server: surreal start -b 0.0.0.0:8082 -u root -p root --log debug
// Create a configuration for the sever specified above.
Config cfg = Config.Create()
.WithEndpoint("127.0.0.1:8082")
.WithDatabase("test")
.WithNamespace("test")
.WithBasicAuth("root", "root")
// Tell the configuration to connect to the server using RPC, and without TLS.
.WithRpc(insecure: true).Build();
// Create a RPC database connection with the configuration.
DatabaseRpc db = new(cfg);
// Connect using the defined connection.
await db.Open();
// Create a struct with the fields we want to insert, nesting is supported.
Person you = new("Max Mustermann", 39, new("Musterstraße 1", 12345, "Musterstadt"), "0123456789", "max@mustermann.de");
// Insert the struct into the database, table = person, id = maxmustermann.
// If id` is not specified it will be random-generated, the id can be read from the response.
RpcResponse create = await db.Create("person:maxmustermann", you);
// Read the struct from the database to verify it was inserted correctly.
RpcResponse select = await db.Select("person:maxmustermann");
if (select.TryGetResult(out Result result)) {
// Prints: {"address":{"city":"Musterstadt","street":"Musterstraße 1","zip":12345},"age":39,"email":"max@mustermann.de","id":"test:maxmustermann","name":"Max Mustermann","phone":"0123456789"}
Console.WriteLine(result.Inner);
Person alsoYou = result.GetObject<Person>();
// Prints: Yes we equals? True
Console.WriteLine($"Yes we equals? {you == alsoYou}");
}
/// <summary>
/// A Person.
/// </summary>
record struct Person(string name, int age, Address address, string phone, string email);
/// <summary>
/// The address of one or more people.
/// </summary>
record struct Address(string street, int zip, string city);
Coverage
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Contributors ✨
Thanks goes to these wonderful people (emoji key):
<table> <tbody> <tr> <td align="center"><a href="https://github.com/ProphetLamb"><img src="https://avatars.githubusercontent.com/u/19748542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ProphetLamb</b></sub></a><br /><a href="https://github.com/ProphetLamb/Surreal.Net/commits?author=ProphetLamb" title="Code">💻</a></td> <td align="center"><a href="https://github.com/StephenGilboy"><img src="https://avatars.githubusercontent.com/u/827735?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephen Gilboy</b></sub></a><br /><a href="https://github.com/ProphetLamb/Surreal.Net/commits?author=StephenGilboy" title="Code">💻</a></td> <td align="center"><a href="https://antoniosbarotsis.github.io/"><img src="https://avatars.githubusercontent.com/u/50240570?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tony</b></sub></a><br /><a href="https://github.com/ProphetLamb/Surreal.Net/commits?author=AntoniosBarotsis" title="Code">💻</a> <a href="https://github.com/ProphetLamb/Surreal.Net/commits?author=AntoniosBarotsis" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/Du-z"><img src="https://avatars.githubusercontent.com/u/16366766?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Brian Duhs</b></sub></a><br /><a href="https://github.com/ProphetLamb/Surreal.Net/commits?author=Du-z" title="Tests">⚠️</a> <a href="https://github.com/ProphetLamb/Surreal.Net/commits?author=Du-z" title="Code">💻</a> <a href="https://github.com/ProphetLamb/Surreal.Net/issues?q=author%3ADu-z" title="Bug reports">🐛</a> <a href="#ideas-Du-z" title="Ideas, Planning, & Feedback">🤔</a></td> <td align="center"><a href="http://siphalor.de/"><img src="https://avatars.githubusercontent.com/u/24505659?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Siphalor</b></sub></a><br /><a href="https://github.com/ProphetLamb/Surreal.Net/commits?author=Siphalor" title="Documentation">📖</a></td> </tr> </tbody> </table>
This project follows the all-contributors specification. Contributions of any kind welcome!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Portable.System.DateTimeOnly (>= 6.0.2)
- System.Memory (>= 4.5.5)
- System.Threading.Tasks.Extensions (>= 4.5.4)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on SurrealDB.Configuration:
Package | Downloads |
---|---|
SurrealDB.Abstractions
Abstractions for the SurrealDB driver |
|
SurrealDB.Driver.Rest
REST based database driver for SurrealDB |
|
SurrealDB.Driver.Rpc
Websocket RPC based database driver for SurrealDB |
GitHub repositories
This package is not used by any popular GitHub repositories.