Kirlovon / aloedb

Light, Embeddable, NoSQL database for Deno 🦕
https://deno.land/x/aloedb
MIT License
140 stars 12 forks source link

Add matchesRegex to helper functions #4

Closed billykirk01 closed 3 years ago

billykirk01 commented 3 years ago

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.

billykirk01 commented 3 years ago

Closing. Regex is already supported. See #5.