提问人:Dmitry 提问时间:11/3/2023 最后编辑:jnpdxDmitry 更新时间:11/3/2023 访问量:57
如何在firebase SwiftUI的地图数组中添加元素
How I can add element in array of map in firebase SwiftUI
问:
我在 Firebase 中有数据,我请求检查 requestdate == 我的日期我想向这个请求日期添加时间
"booking_days": [
{
"date": "__Timestamp__2023-11-05T05:11:54.301Z",
"day_off": false,
"time": [
"11:30"
]
},
{
"date": "__Timestamp__2023-11-04T05:20:17.640Z",
"day_off": false,
"time": [
"14:30"
]
}
],
我尝试像这样的代码
func setBookingTimeForExistingDay(userId: String, bookingDays: BookingDay, existingDay: Date) async throws {
guard let bookingDay = try? encoder.encode(bookingDays) else {
throw URLError(.badURL)
}
let orderBookingTime: [String : Any] = [DBPortfolioModel.CodingKeys.bookingDays.rawValue : FieldValue.arrayUnion([bookingDay])]
try await portfolioUserDocument(userId: userId).setData(orderBookingTime, mergeFields: ["\(existingDay)"])
}
我想要得到这样的结果
"booking_days": [
{
"date": "__Timestamp__2023-11-05T05:11:54.301Z",
"day_off": false,
"time": [
"11:30",
"12:30"
]
},
{
"date": "__Timestamp__2023-11-04T05:20:17.640Z",
"day_off": false,
"time": [
"14:30"
]
}
],
答: 暂无答案
评论
if requestdate == my date
Date