Skip to content

Commit

Permalink
20230922-1-Surrealism_V0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
syf20020816 committed Sep 22, 2023
1 parent e233887 commit 97a7d4d
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 85 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<img src="https://img.shields.io/badge/surrealism-0.2.1-orange?style=flat-square&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=flat-square&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">
<img src="https://img.shields.io/badge/surrealism-0.2.2-orange?style=flat-square&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=flat-square&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">

# Surrealism

- author:syf20020816@outlook.com
- docName:Surrealism README
- createDate:20230506
- updateDate:20230904
- version:0.2.1
- version:0.2.2
- email:syf20020816@outlook.com

## LICEMSE
Expand All @@ -27,7 +27,7 @@ Surrealism relies on Surrealdb's official Rust standard library:surrealdb,The pu

```toml
[dependencies]
surrealism = {version="0.2.1"}
surrealism = {version="0.2.2"}
tokio = { version = "1.28.0", features = ["macros", "rt-multi-thread"] }
```

Expand Down Expand Up @@ -214,14 +214,14 @@ Version {

## Update Des

- 0.2.2(预计发布时间:9月21日前)
- 0.2.2:

- 添加SelectWrapper向LiveSelectWrapper的转变
- 添加Field::Diff,针对LiveSelect语句的构建
- 添加SurrealValue对Geometries的支持,GeoJSON
- 添加所有内置方法Function(未实现)
- 补充ValueTyped类型Geometries,Decimal,Option
- 添加ValueConstructor的new_infer()用于通过默认值推测值类型
- 添加SelectWrapper向LiveSelectWrapper的转变 (Add the transition from SelectWrapper to LiveSelectWrapper)
- 添加Field::Diff,针对LiveSelect语句的构建 (Add Field:: Diff to build the LiveSelect statement)
- 添加SurrealValue对Geometries的支持,GeoJSON (Add SurrealValue support for Geometrics, GeoJSON)
- 添加所有内置方法Function(突然有些困惑,延迟至下个版本) (Add all built-in method functions (suddenly confused, delayed to the next version))
- 补充ValueTyped类型Geometries,Decimal,Option (Supplementing ValueTyped Types Geometry, Decimal, Option)
- 添加ValueConstructor的new_infer()用于通过默认值推测值类型 (Add ValueConstructor::new_Infer() is used to infer the value type from the default value)

- 0.2.1:

Expand Down
4 changes: 2 additions & 2 deletions surrealism/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "surrealism"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
description = "Rust's extension of SurrealDB's official library aims to facilitate and unify various operations"
authors = ["syf20020816@outlook.com"]
Expand All @@ -15,7 +15,7 @@ keywords = ["surrealism", "surrealdb"]
figment = { version = "0.10.10", features = ["toml", "env", "json"] }
serde = "1.0.173"
serde_json = "1.0.103"
surrealdb = "1.0.0-beta.11"
surrealdb = "1.0.0"
log = "0.4.17"
simple_logger = "4.2.0"
futures = "0.3.28"
Expand Down
141 changes: 75 additions & 66 deletions surrealism/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<img src="https://img.shields.io/badge/surrealism-0.2.1-orange?style=flat-square&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=flat-square&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">
<img src="https://img.shields.io/badge/surrealism-0.2.2-orange?style=flat-square&logo=rust&logoColor=%23fff&labelColor=%23DEA584&color=%23DEA584"> <img src="https://img.shields.io/badge/License-MIT-orange?style=flat-square&logoColor=%23fff&labelColor=%2323B898&color=%2323B898">

# Surrealism

- author:syf20020816@outlook.com
- docName:Surrealism README
- createDate:20230506
- updateDate:20230904
- version:0.2.1
- version:0.2.2
- email:syf20020816@outlook.com

## LICEMSE
Expand All @@ -27,24 +27,24 @@ Surrealism relies on Surrealdb's official Rust standard library:surrealdb,The pu

```toml
[dependencies]
surrealism = {version="0.2.1"}
surrealism = {version="0.2.2"}
tokio = { version = "1.28.0", features = ["macros", "rt-multi-thread"] }
```

### add configuration
配置:

- surreal:单机本地连接Single还是分布式连接Multi
- username:用户名
- password:密码
- auth:连接鉴权方式(Root,NS,DB)
- url:连接地址
- port:连接端口
- mode:连接模式(Memory表示内存File表示存到文件中)
- path:存储到文件中的文件地址,使用Memory设置为""即可
- log:日志
- ns:命名空间名称 (auth = NS)⛔
- db:数据库名称 (auth = DB)⛔
- surreal:单机本地连接Single还是分布式连接Multi
- username:用户名
- password:密码
- auth:连接鉴权方式(Root,NS,DB)
- url:连接地址
- port:连接端口
- mode:连接模式(Memory表示内存File表示存到文件中)
- path:存储到文件中的文件地址,使用Memory设置为""即可
- log:日志
- ns:命名空间名称 (auth = NS)⛔
- db:数据库名称 (auth = DB)⛔

可采用JSON或TOML两种配置文件方式

Expand Down Expand Up @@ -84,15 +84,15 @@ The configuration file address can be set to:
#### Surrealism.json(JSON)
```json
{
"surreal" : "Single"
"auth" : "Root"
"username" : "root"
"password" : "syf20020816"
"url" : "127.0.0.1"
"port" : 10086
"mode" : "Memory"
"path" : "E:/Rust/surreal"
"log" : {"level" : "Info", "print" : true,"path" : "E:/surrealism/log" }
"surreal" : "Single"
"auth" : "Root"
"username" : "root"
"password" : "syf20020816"
"url" : "127.0.0.1"
"port" : 10086
"mode" : "Memory"
"path" : "E:/Rust/surreal"
"log" : {"level" : "Info", "print" : true,"path" : "E:/surrealism/log" }
}
```
#### Surrealism.toml(TOML)
Expand Down Expand Up @@ -120,59 +120,59 @@ use surrealism::builder::select::SelectWrapperImpl;

#[derive(Debug, Clone, Serialize, Deserialize)]
struct User {
username: String,
pwd:String,
male: bool,
age: u8,
username: String,
pwd:String,
male: bool,
age: u8,
}

/// create a new user table
/// table_name:user
/// table_id:surrealism
pub fn crate_user_table() -> CreateWrapper {
// create a user data
let user = User {
username: "Tobie".to_string(),
pwd: "Tobie001".to_string(),
male: true,
age: 23,
};
// create table with content
let user_table = SQLBuilderFactory::create()
.table("user")
.id(SurrealID::from("surrealism"))
.content(&user)
.deref_mut();
user_table
// create a user data
let user = User {
username: "Tobie".to_string(),
pwd: "Tobie001".to_string(),
male: true,
age: 23,
};
// create table with content
let user_table = SQLBuilderFactory::create()
.table("user")
.id(SurrealID::from("surrealism"))
.content(&user)
.deref_mut();
user_table
}

#[tokio::main]
async fn main() -> SurrealismRes<()> {
// init service
let mut service = DefaultInitService::new().init();
// use ns:test and db:test
let _ = service.use_commit("test", "test").await?;
// get info from surrealdb
// let info = SQLBuilderFactory::info().db().build();
// let info_res = service.commit_sql(&info).await?;
// dbg!(info_res);
// create a table
// let create_stmt = crate_user_table().build();
// let create_res = service.commit_sql(&create_stmt).await?;
// dbg!(create_res);
// select user::surrealism table
let select = SQLBuilderFactory::select().table("user").id(SurrealID::from("surrealism")).column("*").build();
let select_res = service.commit_sql(&select).await?;
//parse response to any type you want
let res: User = parse_response(select_res);
// [tests\src\main.rs:55] res = User {
// username: "Tobie",
// pwd: "Tobie001",
// male: true,
// age: 23,
// }
dbg!(&res);
Ok(())
// init service
let mut service = DefaultInitService::new().init();
// use ns:test and db:test
let _ = service.use_commit("test", "test").await?;
// get info from surrealdb
// let info = SQLBuilderFactory::info().db().build();
// let info_res = service.commit_sql(&info).await?;
// dbg!(info_res);
// create a table
// let create_stmt = crate_user_table().build();
// let create_res = service.commit_sql(&create_stmt).await?;
// dbg!(create_res);
// select user::surrealism table
let select = SQLBuilderFactory::select().table("user").id(SurrealID::from("surrealism")).column("*").build();
let select_res = service.commit_sql(&select).await?;
//parse response to any type you want
let res: User = parse_response(select_res);
// [tests\src\main.rs:55] res = User {
// username: "Tobie",
// pwd: "Tobie001",
// male: true,
// age: 23,
// }
dbg!(&res);
Ok(())
}
```

Expand Down Expand Up @@ -214,6 +214,15 @@ Version {

## Update Des

- 0.2.2:

- 添加SelectWrapper向LiveSelectWrapper的转变 (Add the transition from SelectWrapper to LiveSelectWrapper)
- 添加Field::Diff,针对LiveSelect语句的构建 (Add Field:: Diff to build the LiveSelect statement)
- 添加SurrealValue对Geometries的支持,GeoJSON (Add SurrealValue support for Geometrics, GeoJSON)
- 添加所有内置方法Function(突然有些困惑,延迟至下个版本) (Add all built-in method functions (suddenly confused, delayed to the next version))
- 补充ValueTyped类型Geometries,Decimal,Option (Supplementing ValueTyped Types Geometry, Decimal, Option)
- 添加ValueConstructor的new_infer()用于通过默认值推测值类型 (Add ValueConstructor::new_Infer() is used to infer the value type from the default value)

- 0.2.1:

- 添加SurrealDB内置方法Function (Add SurrealDB built-in method Function)
Expand Down
6 changes: 3 additions & 3 deletions tests/src/examples/quickstart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ async fn main() -> SurrealismRes<()> {
// let info_res = service.commit_sql(&info).await?;
// dbg!(info_res);
// create a table
// let create_stmt = crate_user_table().build();
// let create_res = service.commit_sql(&create_stmt).await?;
let create_stmt = crate_user_table().build();
let create_res = service.commit_sql(&create_stmt).await?;
// dbg!(create_res);
// select user::surrealism table
let select = SQLBuilderFactory::select().table("user").id(SurrealID::from("surrealism")).column("*").build();
let select = SQLBuilderFactory::select().table("user").id(SurrealID::from("surrealism")).column("*",None).build();
let select_res = service.commit_sql(&select).await?;
//parse response to any type you want
let res: User = parse_response(select_res);
Expand Down
8 changes: 4 additions & 4 deletions tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use surrealism::builder::select::SelectWrapperImpl;
#[derive(Debug, Clone, Serialize, Deserialize)]
struct User {
username: String,
pwd:String,
pwd: String,
male: bool,
age: u8,
}
Expand Down Expand Up @@ -43,11 +43,11 @@ async fn main() -> SurrealismRes<()> {
// let info_res = service.commit_sql(&info).await?;
// dbg!(info_res);
// create a table
// let create_stmt = crate_user_table().build();
// let create_res = service.commit_sql(&create_stmt).await?;
let create_stmt = crate_user_table().build();
let create_res = service.commit_sql(&create_stmt).await?;
// dbg!(create_res);
// select user::surrealism table
let select = SQLBuilderFactory::select().table("user").id(SurrealID::from("surrealism")).column("*").build();
let select = SQLBuilderFactory::select().table("user").id(SurrealID::from("surrealism")).column("*", None).build();
let select_res = service.commit_sql(&select).await?;
//parse response to any type you want
let res: User = parse_response(select_res);
Expand Down

0 comments on commit 97a7d4d

Please sign in to comment.