QueryBuilder

  • Given a ForumPost, Forum, or Category query, adds filters to the query to filter out entities in categories the current user cannot see. Joins the Category (and the Forum, if necessary) to the query to do this.

    Declaration

    Swift

    @discardableResult
    func categoryAccessFilter(for possibleUser: UserCacheData?) -> <<error type>>
  • Declaration

    Swift

    @discardableResult
    func joinWithFilter<LocalField, Foreign, ForeignField>(method: DatabaseQuery.Join.Method = .inner, 
    		from: KeyPath<Model, LocalField>, to: KeyPath<Foreign, ForeignField>, otherFilters: [DatabaseQuery.Filter]) -> Self 	
       		where Foreign: Schema, ForeignField: QueryableProperty, LocalField: QueryableProperty, 
       		ForeignField.Value == LocalField.Value
  • Uses Postgres full text search capabilities for improved search when using a Postgres db. This fn is modeled after the many filter() methods in FluentKit’s QueryBuilder+Filter.swift.

    Declaration

    Swift

    @discardableResult
    public func fullTextFilter<Field>(_ field: KeyPath<Model, Field>, _ value: String) -> Self
    where Field: QueryableProperty, Field.Model == Model, Field.Value == String
  • Declaration

    Swift

    @discardableResult
    public func fullTextFilter<Joined, Field>(
    	_ joined: Joined.Type,
    	_ field: KeyPath<Joined, Field>,
    	_ value: String
    ) -> Self
    where Joined: Schema, Field: QueryableProperty, Field.Model == Joined, Field.Value == String