1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
use IntoQuery;
use surrql;
/// Query to read an artist by their name.
///
/// Compiles to:
/// ```sql, ignore
/// SELECT * FROM artist WHERE name = $name LIMIT 1
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::read_by_name;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = read_by_name();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "SELECT * FROM artist WHERE name = $name LIMIT 1".into_query().unwrap()
/// );
/// ```
pub const
/// Query to read a artists by their names.
///
/// Compiles to:
/// ```sql, ignore
/// SELECT * FROM artist WHERE name IN $names
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::read_by_names;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = read_by_names();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "SELECT * FROM artist WHERE name IN $names".into_query().unwrap()
/// );
/// ```
pub const
/// Query to read the albums by an artist.
///
/// Compiles to:
/// ```sql, ignore
/// SELECT * FROM $id->artist_to_album.out
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::read_albums;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = read_albums();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "SELECT * FROM $id->artist_to_album.out".into_query().unwrap()
/// );
/// ```
pub const
/// Query to relate an artist to an album.
///
/// Compiles to:
/// ```sql, ignore
/// RELATE $id->artist_to_album->$album
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::add_album;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = add_album();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "RELATE $id->artist_to_album->$album".into_query().unwrap()
/// );
/// ```
pub const
/// Query to relate artists to an album.
///
/// Compiles to:
/// ```sql, ignore
/// RELATE $ids->artist_to_album->$album
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::add_album_to_artists;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = add_album_to_artists();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "RELATE $ids->artist_to_album->$album".into_query().unwrap()
/// );
/// ```
pub const
/// Query to relate an artists to songs.
///
/// Compiles to:
/// ```sql, ignore
/// RELATE $id->artist_to_song->$songs
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::add_song;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = add_song();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "RELATE $id->artist_to_song->$songs".into_query().unwrap()
/// );
/// ```
pub const
/// Query to remove songs from an artist.
///
/// Compiles to:
/// ```sql, ignore
/// DELETE $artist->artist_to_song WHERE out == $song
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::remove_song;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = remove_song();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "DELETE $artist->artist_to_song WHERE out == $song".into_query().unwrap()
/// );
/// ```
pub const
/// Query to read all the songs associated with an artist.
///
/// Compiles to:
/// ```sql, ignore
/// SELECT * FROM array::union($artist->artist_to_song.out, $artist->artist_to_album->album->album_to_song.out)
/// ```
///
/// # Example
///
/// ```ignore
/// # use pretty_assertions::assert_eq;
/// use mecomp_storage::db::crud::queries::artist::read_songs;
/// use surrealdb::opt::IntoQuery;
///
/// let statement = read_songs();
/// assert_eq!(
/// statement.into_query().unwrap(),
/// "SELECT * FROM array::union($artist->artist_to_song.out, $artist->artist_to_album->album->album_to_song.out)".into_query().unwrap()
/// );
/// ```
pub const