This repository has been archived by the owner on Oct 3, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fulton
committed
Feb 21, 2020
1 parent
b5ebee9
commit f39e84d
Showing
4 changed files
with
24 additions
and
16 deletions.
There are no files selected for viewing
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
17 changes: 14 additions & 3 deletions
17
src/main/java/com/andromeda/araserver/util/CosmosClients.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
package com.andromeda.araserver.util | ||
|
||
import com.microsoft.azure.documentdb.ConnectionPolicy | ||
import com.microsoft.azure.documentdb.ConsistencyLevel | ||
import com.microsoft.azure.documentdb.DocumentClient | ||
import com.microsoft.azure.documentdb.* | ||
import com.microsoft.azure.documentdb.Document | ||
|
||
object CosmosClients { | ||
private val dbLink = System.getenv("IOTDB") | ||
val client = DocumentClient("https://ara-account-data.documents.azure.com:443/", dbLink, ConnectionPolicy(), ConsistencyLevel.Session) | ||
fun getKeyAsPK(userId: String): PartitionKey { | ||
return PartitionKey(getKey(userId)) | ||
} | ||
fun getKey(userId:String): String { | ||
return "user-$userId" | ||
} | ||
fun feedResponse(options: FeedOptions, key: String, client: DocumentClient): FeedResponse<Document> { | ||
options.partitionKey = CosmosClients.getKeyAsPK(key) | ||
val queryResults: FeedResponse<Document> = | ||
client.queryDocuments("/dbs/Ara-android-database/colls/Ara-android-collection", "SELECT * FROM c", options) | ||
return queryResults | ||
} | ||
|
||
} |
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
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