Sub SELECT_ALL As List
If ShowLog Then
Log($"SDUIPocketBase.${sTableName}.SELECT_ALL"$)
End If
If Schema.Size = 0 Then
BANano.Throw($"SDUIPocketBase.SELECT_ALL: ${sTableName} - please execute SchemaAdd?? first to define your table schema!"$)
Return Null
End If
'
For Each fld As String In Schema.keys
Dim fldType As String = Schema.Get(fld)
If fldType = DB_FILE Then
FILE_FIELD(fld, $"${fld}url"$)
End If
Next
result.Initialize
Dim qsort As String = Join(",", orderByL)
Dim qflds As String = Join(",", flds)
Dim qexpand As String = Join(",", expand)
'Dim allRecords As List
'allRecords.Initialize
Try
Dim page As Int = 1
Dim totalPages As Int = 1
Do While page <= totalPages
Dim opt As Map = CreateMap()
opt.Put("page", page)
opt.Put("perPage", batchSize)
If qsort <> "" Then opt.Put("sort", qsort)
If qflds <> "" Then opt.Put("fields", qflds)
If qexpand <> "" Then opt.Put("expand", qexpand)
opt.Put("cache", "no-store")
'If skipTotal <> "" Then opt.Put("skipTotal", skipTotal)
If headers.Size > 0 Then opt.Put("headers", headers)
If ShowLog Then
Log($"SDUIPocketBase.SELECT_ALL page ${page} => ${BANano.ToJson(opt)}"$)
End If
Dim res As Map = BANano.Await(client.RunMethod("collection", sTableName).RunMethod("getList", Array(page, batchSize, opt)))
Dim items As List = res.Get("items")
If page = 1 Then totalPages = res.Get("totalPages")
' Process file fields if needed
If fileFields.Size > 0 Then
For rCnt = 0 To items.Size - 1
Dim r As Map = items.Get(rCnt)
For Each fk As String In fileFields.Keys
Dim fv As String = fileFields.Get(fk)
Dim fk1 As String = r.Get(fk)
Dim pk1 As String = r.Get(PrimaryKey)
fk1 = CStr(fk1).trim
If fk1 <> "" Then
Dim fk2 As String = $"${baseURL}/api/files/${sTableName}/${pk1}/${fk1}"$
r.Put(fv, fk2)
If GetFiles Then
Dim fdata As String = BANano.Await(BANano.GetFileAsDataURL(fk2, Null))
Dim bisBase64Image As Boolean = BANano.Await(isBase64Image(fdata))
If bisBase64Image Then
r.Put(fk, fdata)
Else
r.Put(fk, "")
End If
End If
End If
Next
items.Set(rCnt, r)
Next
End If
result.AddAll(items)
page = page + 1
Loop
Catch
Log($"SELECT_ALL: ${LastException.message}"$)
End Try
RowCount = result.Size
lastPosition = -1
Return result
End Sub