MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / update_collection

Function update_collection

tests/collection_tests.rs:171–205  ·  view source on GitHub ↗
(db: &DatabaseConnection)

Source from the content-addressed store, hash-verified

169}
170
171pub async fn update_collection(db: &DatabaseConnection) -> Result<(), DbErr> {
172 use collection::*;
173
174 let uuid = Uuid::new_v4();
175 let model = Entity::find_by_id(1).one(db).await?.unwrap();
176
177 ActiveModel {
178 integers: Set(vec![4, 5, 6]),
179 integers_opt: Set(Some(vec![4, 5, 6])),
180 teas: Set(vec![Tea::EverydayTea]),
181 teas_opt: Set(Some(vec![Tea::EverydayTea])),
182 colors: Set(vec![Color::White]),
183 colors_opt: Set(Some(vec![Color::White])),
184 ..model.into_active_model()
185 }
186 .update(db)
187 .await?;
188
189 ActiveModel {
190 id: Unchanged(3),
191 name: Set("Collection 3".into()),
192 integers: Set(vec![3, 1, 4]),
193 integers_opt: Set(None),
194 teas: Set(vec![Tea::EverydayTea]),
195 teas_opt: Set(None),
196 colors: Set(vec![Color::White]),
197 colors_opt: Set(None),
198 uuid: Set(vec![uuid]),
199 uuid_hyphenated: Set(vec![uuid.hyphenated()]),
200 }
201 .update(db)
202 .await?;
203
204 Ok(())
205}
206
207pub async fn select_collection(db: &DatabaseConnection) -> Result<(), DbErr> {
208 use collection::*;

Callers 1

mainFunction · 0.85

Calls 4

unwrapMethod · 0.80
into_active_modelMethod · 0.80
oneMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected