-
Notifications
You must be signed in to change notification settings - Fork 7
/
utils.go
67 lines (60 loc) · 2.64 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package gocosmos
import "reflect"
const (
httpHeaderContentType = "Content-Type"
httpHeaderAccept = "Accept"
httpHeaderAuthorization = "Authorization"
httpHeaderIfMatch = "If-Match"
httpHeaderIfNoneMatch = "If-None-Match"
restApiHeaderVersion = "x-ms-version"
restApiHeaderDate = "x-ms-date"
restApiHeaderOfferThroughput = "x-ms-offer-throughput"
restApiHeaderOfferAutopilotSettings = "x-ms-cosmos-offer-autopilot-settings"
restApiHeaderIsUpsert = "x-ms-documentdb-is-upsert"
restApiHeaderIndexingDirective = "x-ms-indexing-directive"
restApiHeaderPartitionKey = "x-ms-documentdb-partitionkey"
restApiHeaderPartitionKeyRangeId = "x-ms-documentdb-partitionkeyrangeid"
restApiHeaderConsistencyLevel = "x-ms-consistency-level"
restApiHeaderSessionToken = "x-ms-session-token"
restApiHeaderContinuation = "x-ms-continuation"
restApiHeaderPageSize = "x-ms-max-item-count"
restApiHeaderEnableCrossPartitionQuery = "x-ms-documentdb-query-enablecrosspartition"
restApiHeaderParallelizeCrossPartitionQuery = "x-ms-documentdb-query-parallelizecrosspartitionquery"
restApiHeaderIsQuery = "x-ms-documentdb-isquery"
restApiHeaderIsQueryPlanRequest = "x-ms-cosmos-is-query-plan-request"
restApiHeaderMigrateToManualThroughput = "x-ms-cosmos-migrate-offer-to-manual-throughput"
restApiHeaderMigrateToAutopilotThroughput = "x-ms-cosmos-migrate-offer-to-autopilot"
restApiHeaderSupportedQueryFeatures = "x-ms-cosmos-supported-query-features"
restApiHeaderPopulateMetrics = "x-ms-documentdb-populatequerymetrics"
restApiHeaderIncremental = "A-IM"
restApiParamIndexingPolicy = "indexingPolicy"
restApiParamUniqueKeyPolicy = "uniqueKeyPolicy"
restApiParamPartitionKey = "partitionKey"
restApiParamQuery = "query"
restApiParamParameters = "parameters"
restApiParamContent = "content"
respHeaderRequestCharge = "X-MS-REQUEST-CHARGE"
respHeaderSessionToken = "X-MS-SESSION-TOKEN"
respHeaderContinuation = "X-MS-CONTINUATION"
respHeaderEtag = "ETAG"
docFieldId = "id"
)
func goTypeToCosmosDbType(typ reflect.Type) string {
if typ == nil {
return ""
}
switch typ.Kind() {
case reflect.Bool:
return "BOOLEAN"
case reflect.String:
return "STRING"
case reflect.Float32, reflect.Float64:
return "NUMBER"
case reflect.Array, reflect.Slice:
return "ARRAY"
case reflect.Map:
return "MAP"
default:
return ""
}
}