0

Hi i am trying to fetch one single column list in DbFlow

I get all match details when i use this

 public List<Match> getMatchDetails() {
        return SQLite.select()
                .from(Match.class)
                .queryList();
    }

But I actually need a list of scores of all matches, so I tried to fetch score details like this.

  public List<String> getScore() {
        return SQLite.select(Match_Table.score)   // (score is string)
                .from(Match.class)
                .queryList();
    }



 But still I can fetch details as List<Match> and not List<String>. Am I doing anything wrong?
Nivedh
  • 971
  • 1
  • 8
  • 19

1 Answers1

0

I wanted to achieve the same, but I could't get the column type values, because queryList() queries for all of the results the statement returns from a DB cursor in the form of the TModel (your table class Match). I ended up with the following:

public List<String> getScore() {
    List<String> result = new ArrayList<>();
    for (Match match: SQLite.select(Match_Table.score).from(Match.class).queryList()) {
        result.add(match.getScore());
    }
    return result;
}

This can be done for single query, but I couldn't find how to achieve for list:

String score = SQLite.select(Match_Table.score).from(Match.class).where(Condition.column(Match_Table.score.getNameAlias()).is("somescore")).querySingle().getScore();
nikolaDev
  • 1,802
  • 2
  • 14
  • 15
  • Thankyou @NikolaDev I have tried these methods. But I dont understand why I cant get a particular column in DBFlow. SQLite.select(Match_Table.score) and SQLite.select() both are returning same Match_Table model – Nivedh Oct 28 '16 at 05:39