Last active
August 30, 2019 08:47
-
-
Save martijnlentink/861a6543cd225daf3ac1e4c442a3ed8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
Base64Encode = (str as text) => Binary.ToText(Text.ToBinary(str, BinaryEncoding.Base64)), | |
CreateContinuationTokens = (partitionkey as text, rowkey as text) => | |
let | |
tokenPrefix = "1", | |
combineToken = "!", | |
encodedPartition = Base64Encode(partitionkey), | |
encodedRow = Base64Encode(rowkey), | |
nextPartKey = Text.Combine({tokenPrefix, Text.From(Text.Length(encodedPartition)), encodedPartition}, combineToken), | |
nextRowKey = Text.Combine({tokenPrefix, Text.From(Text.Length(encodedRow)), encodedRow}, combineToken), | |
result = [ NextPartitionKey = nextPartKey, NextRowKey = nextRowKey] | |
in | |
result, | |
Func = (url as text, query as record, optional continuationTokens as record) => | |
let | |
queryCombine = if continuationTokens = null then query else Record.Combine({query, continuationTokens}), | |
result = Json.Document(Web.Contents(url, [ Headers=[Accept="application/json;odata=nometadata"], Query = queryCombine ])), | |
resultAsList = result[value], | |
lastInList = List.Last(resultAsList), | |
tokens = CreateContinuationTokens(lastInList[PartitionKey], lastInList[RowKey]), | |
resultList = if List.Count(resultAsList) > 1 then List.Combine({resultAsList, RecursiveTableStorage(url, query, tokens)}) else resultAsList | |
in | |
resultList | |
in | |
Func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment