Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
edit working
Browse files Browse the repository at this point in the history
  • Loading branch information
fulton committed Apr 29, 2020
1 parent 1743c59 commit 2327f2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/andromeda/araserver/util/DatabaseClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.mongodb.connection.ClusterSettings
import com.mongodb.connection.SslSettings
import org.bson.Document
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates
import java.util.*
import kotlin.collections.ArrayList

Expand Down Expand Up @@ -49,7 +50,10 @@ class DatabaseClient {
if (checkOnList && !database.listCollectionNames().contains(userId)) database.createCollection(userId)
}

fun edit() {
fun edit(userId: String, id: String, newData: Any) {
val toJson = Gson().toJson(newData)
val find = database.getCollection(userId).updateOne(Filters.eq("_id", id), Updates.set("document", Document.parse(toJson) ))

}

fun <T> get(userId: String, id: String, clazz: Class<T>): T? {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/andromeda/araserver/test/DBtest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DBtest {
message.forEach {
println(it)
}
databaseClient.edit(id, "test", OutputModel("v2", "", "kldshjfiorbhgoiu", "", "", ""))
println(databaseClient.get<OutputModel>("test", id, OutputModel::class.java))
println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
databaseClient.delete("test", id)
Expand Down

0 comments on commit 2327f2b

Please sign in to comment.