Kirlovon/aloedb

Add matchesRegex to helper functions

billykirk01 opened this issue · 1 comments

Hi @Kirlovon,

Would you be willing to accept a PR to include a matchesRegex helper function in lib/helpers.ts?

I am thinking something like the below:

/**
 * Selects documents where the value of a field matches a regular expression.
 * @param value
 */
export function matchesRegex(expression: RegExp) {
	return (target: Readonly<DocumentValue>) => isString(target) && expression.test(target);
}

With a use case being something like this:

const regExp = new RegExp("/foo/g");

db.findMany({ someField: matchesRegex(regExp) });

If you are willing to accept this I will write a PR to add this feature.

Thanks for all of your work on this project so far. I have really enjoyed using it.

Closing. Regex is already supported. See #5.