chore(git): add attributes

This commit is contained in:
ZhuJHua
2024-12-01 02:30:47 +08:00
parent 64d81d198b
commit ffa5bcaf4e
2 changed files with 45 additions and 0 deletions

1
.gitattributes vendored
View File

@@ -1 +1,2 @@
*.tflite filter=lfs diff=lfs merge=lfs -text
* text=auto eol=lf

View File

@@ -0,0 +1,44 @@
package cn.yooss.util
/*
* Author: ZhuJHua
* Date: 2024/11/25 22:08
* Description: Database
*/
import com.mongodb.ConnectionString
import com.mongodb.MongoClientSettings
import com.mongodb.ServerApi
import com.mongodb.ServerApiVersion
import com.mongodb.kotlin.client.coroutine.MongoClient
import kotlinx.coroutines.runBlocking
import org.bson.Document
object MongoClientConnectionExample {
fun main() {
// Replace the placeholders with your credentials and hostname
val connectionString =
""
val serverApi = ServerApi.builder()
.version(ServerApiVersion.V1)
.build()
val mongoClientSettings = MongoClientSettings.builder()
.applyConnectionString(ConnectionString(connectionString))
.serverApi(serverApi)
.build()
// Create a new client and connect to the server
MongoClient.create(mongoClientSettings).use { mongoClient ->
val database = mongoClient.getDatabase("admin")
runBlocking {
database.runCommand(Document("ping", 1))
}
println("Pinged your deployment. You successfully connected to MongoDB!")
}
}
}