1use crate::error::QuickDbResult;
4use crate::types::*;
5use std::collections::HashMap;
6use tokio::sync::oneshot;
7
8#[derive(Debug)]
10pub enum OdmRequest {
11 Create {
12 collection: String,
13 data: HashMap<String, DataValue>,
14 alias: Option<String>,
15 response: oneshot::Sender<QuickDbResult<DataValue>>,
16 },
17 FindById {
18 collection: String,
19 id: String,
20 alias: Option<String>,
21 response: oneshot::Sender<QuickDbResult<Option<DataValue>>>,
22 },
23 Find {
24 collection: String,
25 conditions: Vec<QueryCondition>,
26 options: Option<QueryOptions>,
27 alias: Option<String>,
28 response: oneshot::Sender<QuickDbResult<Vec<DataValue>>>,
29 },
30 FindWithCacheControl {
31 collection: String,
32 conditions: Vec<QueryCondition>,
33 options: Option<QueryOptions>,
34 alias: Option<String>,
35 bypass_cache: bool,
36 response: oneshot::Sender<QuickDbResult<Vec<DataValue>>>,
37 },
38 FindWithGroups {
39 collection: String,
40 condition_groups: Vec<QueryConditionGroup>,
41 options: Option<QueryOptions>,
42 alias: Option<String>,
43 response: oneshot::Sender<QuickDbResult<Vec<DataValue>>>,
44 },
45 FindWithGroupsWithCacheControl {
46 collection: String,
47 condition_groups: Vec<QueryConditionGroup>,
48 options: Option<QueryOptions>,
49 alias: Option<String>,
50 bypass_cache: bool,
51 response: oneshot::Sender<QuickDbResult<Vec<DataValue>>>,
52 },
53 Update {
54 collection: String,
55 conditions: Vec<QueryCondition>,
56 updates: HashMap<String, DataValue>,
57 alias: Option<String>,
58 response: oneshot::Sender<QuickDbResult<u64>>,
59 },
60 UpdateWithOperations {
61 collection: String,
62 conditions: Vec<QueryCondition>,
63 operations: Vec<crate::types::UpdateOperation>,
64 alias: Option<String>,
65 response: oneshot::Sender<QuickDbResult<u64>>,
66 },
67 UpdateById {
68 collection: String,
69 id: String,
70 updates: HashMap<String, DataValue>,
71 alias: Option<String>,
72 response: oneshot::Sender<QuickDbResult<bool>>,
73 },
74 Delete {
75 collection: String,
76 conditions: Vec<QueryCondition>,
77 alias: Option<String>,
78 response: oneshot::Sender<QuickDbResult<u64>>,
79 },
80 DeleteById {
81 collection: String,
82 id: String,
83 alias: Option<String>,
84 response: oneshot::Sender<QuickDbResult<bool>>,
85 },
86 Count {
87 collection: String,
88 conditions: Vec<QueryCondition>,
89 alias: Option<String>,
90 response: oneshot::Sender<QuickDbResult<u64>>,
91 },
92 GetServerVersion {
93 alias: Option<String>,
94 response: oneshot::Sender<QuickDbResult<String>>,
95 },
96 CreateStoredProcedure {
97 config: crate::stored_procedure::StoredProcedureConfig,
98 response:
99 oneshot::Sender<QuickDbResult<crate::stored_procedure::StoredProcedureCreateResult>>,
100 },
101 ExecuteStoredProcedure {
102 procedure_name: String,
103 database_alias: Option<String>,
104 params: Option<std::collections::HashMap<String, crate::types::DataValue>>,
105 response:
106 oneshot::Sender<QuickDbResult<crate::stored_procedure::StoredProcedureQueryResult>>,
107 },
108}