import * as lf from 'lovefield' ; import { StatementType } from '../../interface' ; export function predicatableQuery ( db , table , predicate , type , ... columns ) ; export function predicatableQuery ( db , table , predicate , type , ... columns ) ; export function predicatableQuery ( db , table , predicate , type , ... columns ) ; export function predicatableQuery ( db , table , predicate , type , ... columns ) { let query ; switch ( type ) { case StatementType . Select : query = db . select ( ... columns ) . from ( table ) ; break ; case StatementType . Delete : query = db . delete ( ) . from ( table ) ; break ; case StatementType . Update : query = db . update ( table ) ; break ; default : throw TypeError ( 'unreachable code path' ) ; } return predicate ? query . where ( predicate ) : query ; }