mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 00:10:37 +00:00
unverified $regex
implmentation
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
be4e3a8cb5
commit
d41af86109
@ -43,6 +43,18 @@ const predicates: Record<string, PredicateFactory> = {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
$regex: (o: { $regex: string, $options: string }, propertyKey: string): Predicate => {
|
||||||
|
const re = new RegExp(o.$regex, o.$options)
|
||||||
|
return (docs: Doc[]): Doc[] => {
|
||||||
|
const result: Doc[] = []
|
||||||
|
for (const doc of docs) {
|
||||||
|
const value = (doc as any)[propertyKey] as string
|
||||||
|
if (value.match(re) !== null) result.push(doc)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user