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
Apr 27, 2020
1 parent
ad34354
commit 54006e0
Showing
2 changed files
with
34 additions
and
3 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
36 changes: 33 additions & 3 deletions
36
src/main/java/com/andromeda/araserver/util/DatabaseClient.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,18 +1,48 @@ | ||
package com.andromeda.araserver.util | ||
|
||
import com.mongodb.MongoClient | ||
import com.mongodb.MongoClientSettings | ||
import com.mongodb.MongoCredential | ||
import com.mongodb.ServerAddress | ||
import com.mongodb.client.MongoClients | ||
import com.mongodb.connection.ClusterSettings | ||
import com.mongodb.connection.SslSettings | ||
import java.util.* | ||
import kotlin.collections.ArrayList | ||
|
||
|
||
object DatabaseClient { | ||
val address:String = System.getenv("dblink") | ||
val password = System.getenv("dbpassword") | ||
val dbname = System.getenv("dbname") | ||
val collectionName = System.getenv("collname") | ||
val cred = MongoCredential.createCredential("ara", dbname, password.toCharArray()) | ||
var settings = MongoClientSettings.builder() | ||
.credential(cred) | ||
.applyToSslSettings { builder: SslSettings.Builder -> | ||
builder.enabled( | ||
true | ||
) | ||
} | ||
.applyToClusterSettings { builder: ClusterSettings.Builder -> | ||
builder.hosts( | ||
Arrays.asList(ServerAddress(address)) | ||
) | ||
} | ||
.build() | ||
val client = MongoClients.create(settings) | ||
val database = client.getDatabase(dbname) | ||
val collection = database.getCollection(collectionName) | ||
fun new(){ | ||
|
||
} | ||
fun edit(){ | ||
|
||
} | ||
fun <T>get():T{ | ||
fun <T>get(userId:String, id:String):T{ | ||
|
||
} | ||
fun <T>getAll():ArrayList<T>{ | ||
fun <T>getAll(userId:String):ArrayList<T>{ | ||
|
||
} | ||
|
||
} |