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

Function insert_collection

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

Source from the content-addressed store, hash-verified

23}
24
25pub async fn insert_collection(db: &DatabaseConnection) -> Result<(), DbErr> {
26 use collection::*;
27
28 let uuid = Uuid::new_v4();
29
30 assert_eq!(
31 Model {
32 id: 1,
33 name: "Collection 1".into(),
34 integers: vec![1, 2, 3],
35 integers_opt: Some(vec![1, 2, 3]),
36 teas: vec![Tea::BreakfastTea],
37 teas_opt: Some(vec![Tea::BreakfastTea]),
38 colors: vec![Color::Black],
39 colors_opt: Some(vec![Color::Black]),
40 uuid: vec![uuid],
41 uuid_hyphenated: vec![uuid.hyphenated()],
42 }
43 .into_active_model()
44 .insert(db)
45 .await?,
46 Model {
47 id: 1,
48 name: "Collection 1".into(),
49 integers: vec![1, 2, 3],
50 integers_opt: Some(vec![1, 2, 3]),
51 teas: vec![Tea::BreakfastTea],
52 teas_opt: Some(vec![Tea::BreakfastTea]),
53 colors: vec![Color::Black],
54 colors_opt: Some(vec![Color::Black]),
55 uuid: vec![uuid],
56 uuid_hyphenated: vec![uuid.hyphenated()],
57 }
58 );
59
60 assert_eq!(
61 Model {
62 id: 2,
63 name: "Collection 2".into(),
64 integers: vec![10, 9],
65 integers_opt: None,
66 teas: vec![Tea::BreakfastTea],
67 teas_opt: None,
68 colors: vec![Color::Black],
69 colors_opt: None,
70 uuid: vec![uuid],
71 uuid_hyphenated: vec![uuid.hyphenated()],
72 }
73 .into_active_model()
74 .insert(db)
75 .await?,
76 Model {
77 id: 2,
78 name: "Collection 2".into(),
79 integers: vec![10, 9],
80 integers_opt: None,
81 teas: vec![Tea::BreakfastTea],
82 teas_opt: None,

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected