hey anyone know if this is possible with quick? pr...
# box-products
d
hey anyone know if this is possible with quick? probably I'm overlooking some subselect feature or something
Copy code
scopeWhereFoo() { ... }

instance.whereFoo().get(); // easy peasy

instance.withIfWhereFooIsTrueThenTrueElseFalse() // ???
goal is to add a bit column that is 1 if some scope matches otherwise 0
going with "is self join count greater than 0"
Copy code
function selfJoinFoo() {
		return hasOne(
			relationName = "<this>",
			foreignKey = "<this-key>",
			localKey = "<this-key>"
		).whereFoo()
	}

	function scopeWithFooIsTrue() {
		withCount( "selfJoinFoo as fooIsTrue" )
	}