Open robogeek opened 5 days ago
So... coding this
const res2 = await documentsDAO.selectAll({ renderPath: { sql: ' renderPath regexp \'/index.html$\' ' } }); console.log(res2);
Results in the following error message:
actually, this should give you a compile error, if you would use Typescript (with proper settings); something like this:
Object literal may only specify known properties, and 'sql' does not exist in type 'PropertyComparisons<string | undefined> | Promise<string | (string & Date)>'
and this would give you the hint, hat 'sql' is not meant to be used for property comparison. Supporting this would just complicate the typing without much benefit
But recoding to this:
const res2 = await documentsDAO.selectAll({ sql: ' renderPath regexp \'/index.html$\' ' }); console.log(res2);
Results in a successful execution.
yes this looks good and you should be able to combine this with other expressions using the logical operators;
so e.g:
myDao.selectAll({
and: [{
sql: ' renderPath regexp \'/index.html$\' '
},
{
vpath: {isLike: '%hello%'}
}]
});
For a table defined by sqlite3orm, I have a field renderPath which is a string (TEXT) containing a pathname. I want to perform a SQL query like the following. The regular expression command (regexp) exists in the command-line SQLITE3 on my laptop as shown here.
The following demonstrates how to install the sqlean package, which includes a regexp function, in the SQLITE3 instance created by sqlite3orm.
The request I have for you is
There is an extension package - https://github.com/nalgeon/sqlean - that is installable with an npm package https://www.npmjs.com/package/sqlite3-sqlean - which contains a regular expression extension that functions in the same way.
To install the extension within sqlite3orm, I did the following:
Then in an application I could do this:
This generates the result I needed - the ability to make a database query using a regular expression.
But, my actual goal is using this as one query possibility in a more complex query that is a Filter or Where thingy for use with the selectAll function.
For example the README for the package led me to believe this would work:
So... coding this
Results in the following error message:
But recoding to this:
Results in a successful execution.
FWIW the generated SQL is: