Skip to content

Commit e804615

Browse files
committed
Attempt to allow fuzzy-match filter in fortune-postgres
Notes ----- I am unsure what field of options may be used. The options.query already seemed to be used, so started looking for another field. As I understand it, Adapter.find leaves the possibility of extra fields on the options object unspecified. Therefore, I added the fuzzyMatch field.
1 parent 7d158ec commit e804615

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,14 @@ module.exports = Adapter => class PostgreSQLAdapter extends Adapter {
310310
}
311311
}
312312

313+
for (const field in options.fuzzyMatch) {
314+
let value = options.fuzzyMatch[field]
315+
//We assume the request has been validaded on another level. (so only strings, no arrays, etc...)
316+
index++
317+
parameters.push(inputValue(value))
318+
where.push(`"${field}" ~* $${index}`)
319+
}
320+
313321
where = where.length ? `where ${where.join(' and ')}` : ''
314322

315323
for (const field in options.sort) {

0 commit comments

Comments
 (0)