cypher-query-builder
cypher-query-builder copied to clipboard
Patterns or raw conditions in where clauses
Hi, thanks a lot for this library, it really cleaned up the logic of my recommendation engine :)
One issue I encountered though is that it doesn't seem possible to use patterns in where clauses such as described here. I had to use qb.raw(), but it doesn't fit nicely in it as I have to determine wether .where was already called or not:
const hasWhereClause = !!filter && !!filter.resourceTypeIn;
if (hasWhereClause) {
q.where({
r: {
type: inArray(filter.resourceTypeIn),
},
});
}
q.raw(`${hasWhereClause ? ' AND ' : 'WHERE '}(u)-[:CONSUMED]->(r)`);
Am I missing something, is there a better way to do it already ?
Also if supporting patterns in where conditions is too complex, maybe just adding the ability to add raw conditions in .where() would bring more flexibility already: it would also allow things like
toLower(r.name) CONTAINS toLower($query)
.
Let me know what you think !