質問編集履歴
3
修正後のソース掲載
test
CHANGED
File without changes
|
test
CHANGED
@@ -85,6 +85,24 @@
|
|
85
85
|
}
|
86
86
|
```
|
87
87
|
|
88
|
+
修正後
|
89
|
+
```src/main.rs
|
90
|
+
fn main() {
|
91
|
+
start();
|
92
|
+
}
|
93
|
+
|
94
|
+
pub async fn select_employees(db: &DbConn) -> Result<Optionemployees::Model, DbErr> {
|
95
|
+
let selected: Optionemployees::Model = Employees::find_by_id(1).one(db).await?;
|
96
|
+
Ok(selected)
|
97
|
+
}
|
98
|
+
|
99
|
+
pub async fn start() {
|
100
|
+
let db:DatabaseConnection = establish_connection().await.expect("connection error!");
|
101
|
+
let select_res:Optionemployees::Model = select_employees(&db).await.expect("database select error!");
|
102
|
+
println!("{}", select_res.unwrap().id);
|
103
|
+
}
|
104
|
+
```
|
105
|
+
|
88
106
|
### 試したこと・調べたこと
|
89
107
|
- [x] teratailやGoogle等で検索した
|
90
108
|
- [ ] ソースコードを自分なりに変更した
|
@@ -98,18 +116,3 @@
|
|
98
116
|
・db_connection.rsを参考にしたサイト
|
99
117
|
https://zenn.dev/collabostyle/articles/0641d73f776d80
|
100
118
|
|
101
|
-
・修正後のsrc/main.rs
|
102
|
-
fn main() {
|
103
|
-
start();
|
104
|
-
}
|
105
|
-
|
106
|
-
pub async fn select_employees(db: &DbConn) -> Result<Option<employees::Model>, DbErr> {
|
107
|
-
let selected: Option<employees::Model> = Employees::find_by_id(1).one(db).await?;
|
108
|
-
Ok(selected)
|
109
|
-
}
|
110
|
-
|
111
|
-
pub async fn start() {
|
112
|
-
let db:DatabaseConnection = establish_connection().await.expect("connection error!");
|
113
|
-
let select_res:Option<employees::Model> = select_employees(&db).await.expect("database select error!");
|
114
|
-
println!("{}", select_res.unwrap().id);
|
115
|
-
}
|
2
修正後のソース記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -97,3 +97,19 @@
|
|
97
97
|
### 補足
|
98
98
|
・db_connection.rsを参考にしたサイト
|
99
99
|
https://zenn.dev/collabostyle/articles/0641d73f776d80
|
100
|
+
|
101
|
+
・修正後のsrc/main.rs
|
102
|
+
fn main() {
|
103
|
+
start();
|
104
|
+
}
|
105
|
+
|
106
|
+
pub async fn select_employees(db: &DbConn) -> Result<Option<employees::Model>, DbErr> {
|
107
|
+
let selected: Option<employees::Model> = Employees::find_by_id(1).one(db).await?;
|
108
|
+
Ok(selected)
|
109
|
+
}
|
110
|
+
|
111
|
+
pub async fn start() {
|
112
|
+
let db:DatabaseConnection = establish_connection().await.expect("connection error!");
|
113
|
+
let select_res:Option<employees::Model> = select_employees(&db).await.expect("database select error!");
|
114
|
+
println!("{}", select_res.unwrap().id);
|
115
|
+
}
|
1
タイトル編集
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Rustで
|
1
|
+
Rustでミスマッチタイプエラーを解決できない。
|
test
CHANGED
File without changes
|