Skip to content

Patterns or raw conditions in where clauses #158

@Layvier

Description

@Layvier

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions