hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! The `note` table: one user's rows, listed newest first, deleted together |
| 2 | //! with their attachment rows. |
| 3 | |
| 4 | use crate; |
| 5 | use crateFieldUpdate; |
| 6 | use cratePagedList; |
| 7 | use crate; |
| 8 | use crate; |
| 9 | use crateUserId; |
| 10 | use crateAppError; |
| 11 | |
| 12 | pub async |
| 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 | /// Read a note only if it belongs to `owner`. |
| 42 | pub async |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | pub async |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | /// Request-scoped: no lock spans the handler's read and this write, so an |
| 72 | /// omitted field (`None`) is not written at all. Passing the snapshot's |
| 73 | /// value back instead would revert a concurrent edit of that field — |
| 74 | /// scoping the `SET` alone does not prevent that, the values have to come |
| 75 | /// from the request. Neither column is nullable, so plain `Option` per |
| 76 | /// field says everything there is to say. |
| 77 | pub async |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | /// Delete the note and cascade-remove its attachment rows, returning both: |
| 94 | /// the note, and the attachment rows this transaction actually removed. |
| 95 | /// Blob files on disk are the web layer's to remove, but only for *these* |
| 96 | /// rows — a row uploaded after the caller listed the note's files is |
| 97 | /// deleted here too, and a pre-read snapshot would strand its blob. A crash |
| 98 | /// between commit and unlink leaves at worst an unreachable blob, never a |
| 99 | /// row pointing at nothing. |
| 100 | /// |
| 101 | /// Children first, in one transaction, the way |
| 102 | /// [`crate::db::course::delete`] does it: as two queries, an |
| 103 | /// upload that committed in between kept its row while the note went, and |
| 104 | /// nothing could ever list or delete it again. The `rag_output` sweep rides |
| 105 | /// here too: under real foreign keys a `rag_output` row citing this note |
| 106 | /// would refuse the delete (`ON DELETE NO ACTION`), and the derived rows |
| 107 | /// are exactly the thing that may never outlive its input — the web layer's |
| 108 | /// separate `delete_for_note` call stays, as a harmless idempotent repeat. |
| 109 | pub async |
| 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 |