MIT
Surrealism依托于Surrealdb提供的Rust官方标准库:surrealdb,目的是构建一种更加统一,简单的方式对Surrealdb数据库进行各类操作
Surrealism relies on Surrealdb's official Rust standard library:surrealdb,The purpose is to build a more unified and simple way to perform various operations on Surrealdb database
toml
[dependencies]
surrealism = "0.1.1"
tokio = { version = "1.28.0", features = ["macros", "rt-multi-thread"] }
配置:
- surreal:单机本地连接Single还是分布式连接Multi
- auth:连接鉴权方式(Root,NS,DB)
- username:用户名
- password:密码
- ns:命名空间名称
- db:数据库名称
- url:连接地址
- port:连接端口
- mode:连接模式(Memory:表示内存,File:表示存到文件中)
- path:存储到文件中的文件地址,使用Memory设置为""即可
- logLevel:日志级别(error,warn,info,debug,trace)
可采用JSON或TOML两种配置文件方式
设置配置文件地址可以是: - ./Surrealism.toml - ./configs/Surrealism.toml - ./templates/Surrealism.toml
configuration:
Two configuration file methods can be used: JSON or TOML
The configuration file address can be set to:
❗note:当前SurrealDB仍处于开发阶段,对应连接鉴权方式:NS和DB并为支持,所以使用Surrealism进行配置时请以Root方式进行鉴权连接,不要设置ns和db!
❗note:Currently, SurrealDB is still in the development stage, and the corresponding connection authentication methods are supported: NS and DB. Therefore, when using Surrealsm for configuration, please use Root mode for authentication connections and do not set ns and db!
json
{
"surreal": "Single",
"auth": "Root",
"username": "root",
"password": "syf20020816",
"ns": "",
"db": "",
"url": "127.0.0.1",
"port": "10086",
"mode": "Memory",
"path": "E:/Rust/surreal",
"logLevel": "info"
}
toml
[default]
surreal = "Single"
auth = "Root"
username = "root"
password = "syf20020816"
ns = ""
db = ""
url = "127.0.0.1"
port = "10086"
mode = "Memory"
path = "E:/Rust/surreal"
logLevel="info"
```rust use surrealism::{DefaultInitServiceImpl, SurrealRes};
async fn main() -> SurrealRes<()> { ///初始化连接 ///init connection let db = DefaultInitServiceImpl::new().init().unwrap(); Ok(()) }
```
```bash ▄▄▄▄ ▄▄▄▄ ██ ▄█▀▀▀▀█ ▀▀██ ▀▀ ██▄ ██ ██ ██▄████ ██▄████ ▄████▄ ▄█████▄ ██ ████ ▄▄█████▄ ████▄██▄ ▀████▄ ██ ██ ██▀ ██▀ ██▄▄▄▄██ ▀ ▄▄▄██ ██ ██ ██▄▄▄▄ ▀ ██ ██ ██ ▀██ ██ ██ ██ ██ ██▀▀▀▀▀▀ ▄██▀▀▀██ ██ ██ ▀▀▀▀██▄ ██ ██ ██ █▄▄▄▄▄█▀ ██▄▄▄███ ██ ██ ▀██▄▄▄▄█ ██▄▄▄███ ██▄▄▄ ▄▄▄██▄▄▄ █▄▄▄▄▄██ ██ ██ ██ ▀▀▀▀▀ ▀▀▀▀ ▀▀ ▀▀ ▀▀ ▀▀▀▀▀ ▀▀▀▀ ▀▀ ▀▀▀▀ ▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀
2023-06-09T13:27:51.921Z INFO [surrealism::config::core::init::defaultinitserviceimpl] Configuration Initialization over(配置初始化完成)
2023-06-09T13:27:51.921Z INFO [surrealism::config::core::init::defaultinitserviceimpl] Connection Initialization start(初始化连接检测开始)
2023-06-09T13:27:51.993Z INFO [surrealism::config::core::init::defaultinitserviceimpl] Version {
router: Ok(
Router {
conn: PhantomData
我们可以在根目录中添加banner.txt来添加自己的Logo
We can add banner.txt to the root directory to add our own logo
``` , , /(, ,)\ \ _/ _ / // \ \ (@)(@) // \'="=="='/ ,===/ \===, ",===\ /===," " ,==='------'===, " " "
```