Closed 4WayMitja closed 3 years ago
Relevant link with example using custom select statements: https://moor.simonbinder.eu/docs/using-sql/custom_queries/#custom-select-statements
You can also use the rowId extension on a table. So the usage would look something like this:
final query = select(students).addColumns([students.rowId]);
return query.map((row) => IdWithStudent(row.read(students.rowId, row.readTable(students))));
But I think the easiest way would be to add an alias to the rowid to the table.
Hi based on your solution for newer version I manage to put together solution for older version:
class StudentWithId {
final StudentTableData student;
final int studentId;
StudentWithId(this.student, this.studentId);
}
Future<List<StudentWithId>> getAllWithRowId() {
final query = customSelect('SELECT *, rowid FROM Student);
return query.map((row) => StudentWithId(StudentTableData.fromData(row.data, db), row.readInt('rowid'))).get();
}
I can't get data list with rowid for all rows of my table This is the minimal example code that I have:
using
I would like to obtain IdWithStudent from my Student table. Relevant example from sqlite:
I would like to obtain rowid (studentId) and data (StudentTableData) for all rows of my table I would like an easy way to implement Future<List> getAllWithRowId() for my StudentDao class.