diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-04-20 11:20:12 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-05-01 16:41:02 +0200 |
commit | 0251197e249cc03b65805ed6805da72bf4573529 (patch) | |
tree | 3aae202fd1ea24bac5cd7f2c380ffe50aae189a0 /server/models/utils.ts | |
parent | b8cf27c0f86d205a279d03b83e0e6728f46da67f (diff) | |
download | PeerTube-0251197e249cc03b65805ed6805da72bf4573529.tar.gz PeerTube-0251197e249cc03b65805ed6805da72bf4573529.tar.zst PeerTube-0251197e249cc03b65805ed6805da72bf4573529.zip |
Factorize rest-table and fix/simplify SQL
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r-- | server/models/utils.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts index 7137419a2..bdf2291f0 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -208,13 +208,15 @@ function buildDirectionAndField (value: string) { | |||
208 | } | 208 | } |
209 | 209 | ||
210 | function searchAttribute (sourceField, targetField) { | 210 | function searchAttribute (sourceField, targetField) { |
211 | return sourceField | 211 | if (sourceField) { |
212 | ? { | 212 | return { |
213 | [targetField]: { | 213 | [targetField]: { |
214 | [Op.iLike]: `%${sourceField}%` | 214 | [Op.iLike]: `%${sourceField}%` |
215 | } | 215 | } |
216 | } | 216 | } |
217 | : {} | 217 | } else { |
218 | return {} | ||
219 | } | ||
218 | } | 220 | } |
219 | 221 | ||
220 | // --------------------------------------------------------------------------- | 222 | // --------------------------------------------------------------------------- |