Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.google.auth.oauth2.GoogleCredentials
- import com.google.cloud.datastore.*
- import java.io.File
- import kotlin.random.Random
- import com.oracle.util.Checksums.update
- import com.google.cloud.datastore.TransactionExceptionHandler.build
- import com.google.gson.Gson
- import com.google.cloud.datastore.StructuredQuery.OrderBy
- import com.google.cloud.datastore.Query.newEntityQueryBuilder
- import com.google.cloud.datastore.TransactionExceptionHandler.build
- val names = listOf(
- "! *̣̣ ღ 𝓐𝓶𝓮𝔁𝔂 ღ *̣̣ 🐝",
- "! Afx",
- "! Alshame97",
- "! Christopher Freitas",
- "! ipkez",
- "! Neeko2lo (Rabbit)",
- "! Zhava",
- "! 🍜 GuyNoodle 🍜 !",
- "!!Makahaa!!",
- "! life sucks",
- "Ahnaris",
- "!Boogie",
- "!DARK LORD",
- "!Entheos",
- "!Fia",
- "!Kyle2Hype",
- "!Taki",
- "Dylo",
- "$ ✘‿✘ LLama",
- "!a ॐ",
- "The Cat!",
- "\$aku",
- "\$cott",
- "'** Sir_Guifred **'",
- "-3(",
- "!.!.rall.!.!",
- "-V-",
- "./unnamed",
- ".Ace.",
- ".bit",
- ".Bypass",
- ".Cowboy",
- ".Jura",
- "'Rikka",
- ".KayTV",
- ".Lucas.",
- ".ProudHeart",
- ".𝔗𝔯𝔞𝔦𝔫𝔢𝔯_🅱𝔯𝔢𝔫𝔡𝔞𝔫.",
- "009 Sound System",
- "07 Officer"
- )
- fun main() {
- val gson = Gson()
- val datastore = DatastoreOptions.newBuilder()
- .setProjectId("firestoredatastore-254209")
- .setCredentials(GoogleCredentials.fromStream(File("FirestoreDatastore-f4885100cfa7.json").inputStream()))
- .build()
- .service
- val keyFactory = datastore.newKeyFactory().setKind("TestEntity")
- val key = keyFactory.setKind("TestEntity").newKey()
- // Record a visit to the datastore, storing the IP and timestamp.
- // names.parallelStream().forEach {
- // val newThing = Entity.newBuilder<IncompleteKey>(key)
- // .set("ip_addresses", "88.200.136.211")
- // .set("name", it)
- // .set("rnum", Random.nextLong())
- // .set("isDisabled", Random.nextBoolean()).build()
- // datastore.add(newThing)
- // }
- // println(timePar)
- // println(timesync)
- val single = datastore[keyFactory.newKey(5409299698286592)]
- val newSingle = Entity.newBuilder(single).set("name", "a new name").build()
- datastore.update(newSingle)
- // Retrieve the last 10 visits from the datastore, ordered by timestamp.
- val query = Query.newEntityQueryBuilder()
- .setKind("TestEntity")
- .setFilter(
- StructuredQuery.CompositeFilter.and(
- StructuredQuery.PropertyFilter.eq("isDisabled", false),
- StructuredQuery.PropertyFilter.eq(
- "name",
- "\$aku"
- )
- )
- ).build()
- val results = datastore.run(query).asSequence().map { it as Entity }.map {
- gson.toJson(it.properties)
- }.toList()
- println(results)
- // val newEntities = results.map {
- // Entity.newBuilder(it).set("rnum", 2).build()
- // }.toTypedArray()
- // datastore.update(*newEntities)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement