You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Table
struct Currency {
let code: String
let name: String
let symbol: String
}
@Table
struct Expense {
let id: UUID
let name: String
let amount: Decimal
let currencyCode: Currency.ID
let date: Date
}
// I want to achieve this end result:
@Selection
struct ExpenseModel {
let id: UUID
let name: String
let amount: Decimal
let currency: Currency
let date: Date
}
@Selection
struct GroupedExpenses {
let date: Date
@Column(as: [ExpenseModel].JSONRepresentation.self)
let expenses: [ExpenseModel]
}
and this is the query I'm trying to use:
Expense.
.order { $0.date.desc(nulls: .last) }
.join(Currency.all) { $0.currencyCode.eq($1.code) }
.group(by: \.date)
.select {
// What to do here? I should have 2 arguments: expense and currency,
// but it seems that I have only one.
}
If I do the same query without the group by clause, in the select I have 2 arguments correctly resolved, and I can create the ExpenseModel.
Do you have any suggestions?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All, I have this schema
and this is the query I'm trying to use:
If I do the same query without the group by clause, in the select I have 2 arguments correctly resolved, and I can create the ExpenseModel.
Do you have any suggestions?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions