public static function where($field, $operator, $value, $logical)
    {
        if (gettype($field)=="array") {
            throw new ClusterpointException("\"->where()\" function: passed field selector is not in valid format.", 9002);
        }
        if ($operator===null) {
            return "{$logical} {$field} ";
        } elseif ($value===null) {
            $value = $operator;
            $operator = '==';
        }
        if ($field instanceof Key) {
            $field =  self::field("{$field}");
        }
        if (!($value instanceof Raw)) {
        	if (is_string($value)){
				$value = '"'.Client::escape($value).'"';
			}
			else {
				$value =  json_encode($value);
			}
        }
        return "{$logical} {$field}{$operator}{$value} ";
    }