Code Monkey home page Code Monkey logo

sdk-for-kotlin's Introduction

Appwrite Kotlin SDK

Maven Central License Version Twitter Account Discord

This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check previous releases.

This is the Kotlin SDK for integrating with Appwrite from your Kotlin server-side code. If you're looking for the Android SDK you should check appwrite/sdk-for-android

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Kotlin SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs

Appwrite

Installation

Gradle

Appwrite's Kotlin SDK is hosted on Maven Central. In order to fetch the Appwrite SDK, add this to your root level build.gradle(.kts) file:

repositories {      
    mavenCentral()
}

If you would like to fetch our SNAPSHOT releases, you need to add the SNAPSHOT maven repository to your build.gradle(.kts):

repositories {
    maven {
        url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
    }
}

Next, add the dependency to your project's build.gradle(.kts) file:

implementation("io.appwrite:sdk-for-kotlin:5.0.1")

Maven

Add this to your project's pom.xml file:

<dependencies>
    <dependency>
        <groupId>io.appwrite</groupId>
        <artifactId>sdk-for-kotlin</artifactId>
        <version>5.0.1</version>
    </dependency>
</dependencies>

Getting Started

Init your SDK

Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section.

import io.appwrite.Client
import io.appwrite.services.Account

suspend fun main() {
    val client = Client(context)
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
      .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      .setSelfSigned(true) // Use only on dev mode with a self-signed SSL cert
}

Make Your First Request

Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.

val users = Users(client)
val user = users.create(
    user = ID.unique(),
    email = "[email protected]",
    phone = "+123456789",
    password = "password",
    name = "Walter O'Brien"
)

Full Example

import io.appwrite.Client
import io.appwrite.services.Users
import io.appwrite.ID

suspend fun main() {
    val client = Client(context)
      .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
      .setProject("5df5acd0d48c2") // Your project ID
      .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      .setSelfSigned(true) // Use only on dev mode with a self-signed SSL cert

    val users = Users(client)
    val user = users.create(
        user = ID.unique(),
        email = "[email protected]",
        phone = "+123456789",
        password = "password",
        name = "Walter O'Brien"
    )
}

Error Handling

The Appwrite Kotlin SDK raises AppwriteException object with message, code and response properties. You can handle any errors by catching AppwriteException and present the message to the user or handle it yourself based on the provided error information. Below is an example.

import io.appwrite.Client
import io.appwrite.ID
import io.appwrite.services.Users

suspend fun main() {
    val users = Users(client)
    try {
        val user = users.create(
            user = ID.unique(),
            email = "[email protected]",
            phone = "+123456789",
            password = "password",
            name = "Walter O'Brien"
        )
    } catch (e: AppwriteException) {
        e.printStackTrace()
    }
}

Learn more

You can use the following resources to learn more and get help

Contribution

This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

sdk-for-kotlin's People

Contributors

abnegate avatar christyjacob4 avatar eldadfux avatar kkvanonymous avatar lohanidamodar avatar meldiron avatar stnguyen90 avatar torstendittmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-for-kotlin's Issues

Upgrade our issue templates to use GitHub issue forms โœ๏ธ

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them ๐Ÿคฏ.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? ๐Ÿค” Let us know, and we will assign it to you ๐Ÿ˜Š

Happy Appwriting!

๐Ÿš€ Feature: Migrate SDk to Support to KotlinMultiPlatform

๐Ÿ”– Feature description

Migrate lib to KMP structure and replace following:

  • GSON -> kotlinx.serialization
  • okhttp -> ktor

to support multiple targets like, Android, JVM, IOS, maybe Native too(for MacOS, Windows, Linux).

Are you open to PRs for same ?

๐ŸŽค Pitch

why keep kotlin sdk only scoped to jvm, Kotlin Targets more platforms.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Creating of float show Failure status in Appwrite

๐Ÿ‘Ÿ Reproduction steps
Succesfully created a float through SDK.
appwriteDatabase.createFloatAttribute(collectionId = collection.id, key = "key", min = 0.00, required = false, default = 0.00)

๐Ÿ‘ Expected behavior
Shows succesful Status in Appwrite Server

๐Ÿ‘Ž Actual Behavior
Shows failure Status in Appwrite Server:

image

Error in appwrite-worker-database:
Default value 0 does not match given type double

๐ŸŽฒ Appwrite version
Version 0.12.1

๐Ÿ’ป Operating system
Windows

๐Ÿงฑ Your Environment
Appwrite v0.12.1 - sdk-for-kotlin v0.2.5
Java v11
Kotlin v1.6.10

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?
I checked and didn't find similar issue
๐Ÿข Have you read the Code of Conduct?
I have read the Code of Conduct

๐Ÿ› Bug Report: NullPointerException when trying to fetch teams list

๐Ÿ‘Ÿ Reproduction steps

When I try to fetch teams list using Teams object, I get NPE.

Demo code:

val client = Client().setEndpoint(Application.appWriteEndpoint).setProject(Application.appWriteProjectId).setKey(Application.appWriteApiKey)
val teamsClient = Teams(client)

val teams = teamsClient.list().teams // this line causes NPE, see below

teams.forEach {
    println(it.name)
}

๐Ÿ‘ Expected behavior

Teams list should load.

๐Ÿ‘Ž Actual Behavior

The call crashes with following stack trace:

Exception in thread "OkHttp Dispatcher" java.lang.NullPointerException: null cannot be cast to non-null type kotlin.collections.Map<kotlin.String, kotlin.Any>
	at io.appwrite.models.Team$Companion.from(Team.kt:83)
	at io.appwrite.models.TeamList$Companion.from(TeamList.kt:43)
	at io.appwrite.services.Teams$list$converter$1.invoke(Teams.kt:43)
	at io.appwrite.services.Teams$list$converter$1.invoke(Teams.kt:42)
	at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:507)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

I've investigated the crash and found the point. The error occurs in mapping the Team object's preferences in Team.kt file:

@Suppress("UNCHECKED_CAST")
fun <T> from(
    map: Map<String, Any>,
    nestedType: Class<T>
) = Team<T>(
    id = map["\$id"] as String,
    createdAt = map["\$createdAt"] as String,
    updatedAt = map["\$updatedAt"] as String,
    name = map["name"] as String,
    total = (map["total"] as Number).toLong(),
    prefs = Preferences.from(map = map["prefs"] as Map<String, Any>, nestedType),
)

In last line, where prefs is assigned, actual value of maps["prefs"] is null, while cast expects it to be Map<String, Any>. So the prefs field in data class Team should be nullable, and I suggest that the cast should be rewritten, something like that:

prefs = (map["prefs"] as? Map<String, Any>)?.run { prefs = Preferences.from(map = this, nestedType),

๐ŸŽฒ Appwrite version

Version 1.3.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

I use io.appwrite:sdk-for-kotlin:2.0.0 which automatically fetches all required dependencies.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Using Java v17 doesn't show proper Appwrite Exception message

๐Ÿ‘Ÿ Reproduction steps

When I try call createEnumAttribute from server when the collection exists I get a stacktrace error, similar things happen to Floats. (Integer, Boolean, URL and Email work; IP not tested)

For example:

database.createEnumAttribute(collectionId = "xxxxxx", key = "enumTest", elements = arrayListOf("OPTION"), required = false, default = "OPTION")

database.createFloatAttribute(collectionId = "xxxxxx", key = "floatTest", min = "0.00", required = false, default = "0.00")

๐Ÿ‘ Expected behavior

Proper AppwriteException message (for the floats) when using Java v11
Exception in thread "main" io.appwrite.exceptions.AppwriteException: Invalid default: Value must be a valid float
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.google.gson.internal.ConstructorConstructor$3.construct(ConstructorConstructor.java:110)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
at com.google.gson.Gson.fromJson(Gson.java:932)
at com.google.gson.Gson.fromJson(Gson.java:897)
at com.google.gson.Gson.fromJson(Gson.java:846)
at com.google.gson.Gson.fromJson(Gson.java:817)
at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:371)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

๐Ÿ‘Ž Actual Behavior

Stacktrace for Enums, Floats:

Exception in thread "OkHttp Dispatcher" java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.lang.Throwable.detailMessage accessible: module java.base does not "opens java.lang" to unnamed module @6b0c2d26
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
	at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
	at com.google.gson.Gson.getAdapter(Gson.java:458)
	at com.google.gson.Gson.fromJson(Gson.java:931)
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at com.google.gson.Gson.fromJson(Gson.java:817)
	at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:371)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

  • appwrite 0.12.1
  • io.appwrite:sdk-for-kotlin:0.2.2

other dependencies:
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.10'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10'
implementation "io.appwrite:sdk-for-kotlin:0.2.2"
implementation "com.sun.xml.bind:jaxb-impl:3.0.2"
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2'
implementation "org.apache.logging.log4j:log4j-api-kotlin:1.1.0"
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.13.1"

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Using listCollections and search parameter gives an error 500

๐Ÿ‘Ÿ Reproduction steps
I try to retrieve a list of Collection.
Currently I have a collection with NAME: MEMBER and ID: MEMBER . I try to retrieve this collection with the following
val collectionList = db.listCollections(search = "MEMBER")

๐Ÿ‘ Expected behavior
Get a proper CollectionList object, and a 200 for the call.

๐Ÿ‘Ž Actual Behavior
I get the following errors:

Exception in thread "main" io.appwrite.exceptions.AppwriteException: {"message":"Error: Server Error","code":500,"version":"0.12.1"}
	at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:336)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

In appwrite logging I get the following error:

[Error] File: /usr/src/code/vendor/utopia-php/framework/src/App.php
[Error] Line: 756
[Error] Type: PDOException
[Error] Message: Can't find FULLTEXT index matching the column list
[Error] File: @swoole-src/library/core/Database/PDOStatementProxy.php
[Error] Line: 64

๐ŸŽฒ Appwrite version
Version 0.12.1

๐Ÿ’ป Operating system
Windows

๐Ÿงฑ Your Environment
Appwrite v0.12.1 - sdk-for-kotlin v0.2.4
Java v11
Kotlin v1.6.10

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?
I checked and didn't find similar issue
๐Ÿข Have you read the Code of Conduct?
I have read the Code of Conduct

๐Ÿ“š Maven repositories are not updated

๐Ÿ’ญ Description

Maven repositories are not updated.

Both those versions are released as per releases page but are not available for use.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Wrong response type when creating document

database.createDocument returns DocumentList object response but the SDK waits for Document object response.

Error when executing database.createDocument:

Exception in thread "OkHttp Dispatcher" java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String
	at io.appwrite.models.Document$Companion.from(Document.kt:42)
	at io.appwrite.services.Database$createDocument$converter$1.invoke(Database.kt:770)
	at io.appwrite.services.Database$createDocument$converter$1.invoke(Database.kt:769)
	at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:472)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

The same issue is present on the Android SDK side.

๐Ÿ› Bug Report: Using only search parameter in listCollections results in Error

๐Ÿ‘Ÿ Reproduction steps

Using only search parameter in listCollections results in Error

Try running:
val collectionList = appwriteDatabase.listCollections(search = "COLLECTIONID")

๐Ÿ‘ Expected behavior

If collection exists I would like to receive a proper io.appwrite.models.CollectionList Object

If collection does not exists I would like to receive a proper io.appwrite.models.CollectionList Object, but sum would be 0 and collections would be empty map?

๐Ÿ‘Ž Actual Behavior

Currently results in an error which is not clear (the collection id exists):

Exception in thread "main" io.appwrite.exceptions.AppwriteException: {"message":"Error: Server Error","code":500,"version":"0.12.1"}
	at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:327)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

Looking in appwrite logs:

[Error] File: /usr/src/code/vendor/utopia-php/framework/src/App.php
[Error] Line: 756
[Error] Type: PDOException
[Error] Message: Can't find FULLTEXT index matching the column list
[Error] File: @swoole-src/library/core/Database/PDOStatementProxy.php
[Error] Line: 64

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

Appwrite v0.12.1 - sdk-for-kotlin v0.2.2
Java v11
Kotlin v1.6.10

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report:

๐Ÿ‘Ÿ Reproduction steps

launch(Dispatchers.IO) {
    try {
        val client = Client()
            .setEndpoint("http://127.0.0.1/v1")
            .setProject("619505812e4d0")
            .setKey("94c9dad4e9041994a7470289b01c69......d87bd7d4d27a5ea30c804cae865")
            .setSelfSigned(true)

        val database = io.appwrite.services.Database(client)

        for (i in 0..10000) {
            val response = database.createDocument(
                collectionId = "6195069ccabcf",
                data = mapOf(
                    "userId" to "user${i}@gmail.com",
                    "premiumStatus" to true,
                    "expiredTo" to 123456
                ),
            )
            val json = response.isSuccessful
            log.info("res $i is $json")
            delay(10)
        }

    } catch (e: Exception) {
        log.error("Exception: ", e)
    } catch (er: AppwriteException) {
        log.error("AppwriteException: ", er)
    }
}

๐Ÿ‘ Expected behavior

All this was done for the sake of verification.
It was expected that all documents (data) will be successfully created or the server will not hang from this.

๐Ÿ‘Ž Actual Behavior

The service is now unavailable and does not restart.
Restarting Docker, containers gave no results.

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

I use WSL2

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report:

๐Ÿ‘Ÿ Reproduction steps

When I try used Realtime in Kotlin

๐Ÿ‘ Expected behavior

but import io.appwrite.services.Realtime is error

๐Ÿ‘Ž Actual Behavior

I want use this feature

๐ŸŽฒ Appwrite version

Appwrite Cloud

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

io.appwrite:sdk-for-kotlin:5.0.0

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Filling in string values for max, min or default to create Floats serverside in DB gives an error

๐Ÿ‘Ÿ Reproduction steps

I have tried creating a Float attribute with different ways to write in min, max and default. But none of them seem to work:

appwriteDatabase.createFloatAttribute(collectionId = "collection", key = "floatnumber", min = "0.0000000f", required = false, default = "0.0000000f")
        appwriteDatabase.createFloatAttribute(collectionId = "collection", key = "floatnumber", min = "0.0000000", required = false, default = "0.0000000")
        appwriteDatabase.createFloatAttribute(collectionId = "collection", key = "floatnumber", min = "0", required = false, default = "0")
        appwriteDatabase.createFloatAttribute(collectionId = "collection", key = "floatnumber", min = "0f", required = false, default = "0f")

๐Ÿ‘ Expected behavior

The float value should be created with any of these possibilities.

๐Ÿ‘Ž Actual Behavior

Exception in thread "main" io.appwrite.exceptions.AppwriteException: Invalid default: Value must be a valid float
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

Appwrite v0.12.1 - sdk-for-kotlin v0.2.2
Java v11
Kotlin v1.6.10

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Deletion of collection and recreating it fails and gives a duplication error

๐Ÿ‘Ÿ Reproduction steps
Collection TEST with same ID exists.
Deleting and creating collection gives error in the logs. The collection is succesfully deleted. But the creation fails.

    private var appwriteClient: Client = Client()
        .setEndpoint(APPWRITE_ENDPOINT)
        .setProject(APPWRITE_PROJECT)
        .setKey(APPWRITE_KEY)
        .setSelfSigned(false)
    val appwriteDatabase = Database(appwriteClient)
        
            appwriteDatabase.deleteCollection( "TEST")
            
        val collection: Collection = appwriteDatabase.createCollection(
            collectionId = "TEST",
            name =  "TEST",
            read = ["team:xxx"],
            write = ["team:xxx"],
            permission = "collection"

๐Ÿ‘ Expected behavior
Deletion and creation should work. And once the deletion is executed, it should be possible to create a database with same name and id.

๐Ÿ‘Ž Actual Behavior
Shows the following error in Appwrite where it complains about a dupliocate key.

[Error] Type: PDOException
[Error] Message: Duplicate key name '_index2'
[Error] File: @swoole-src/library/core/Database/PDOStatementProxy.php
[Error] Line: 64

๐ŸŽฒ Appwrite version
Version 0.12.1

๐Ÿ’ป Operating system
Windows

๐Ÿงฑ Your Environment
Appwrite v0.12.1 - sdk-for-kotlin v0.2.5
Java v11
Kotlin v1.6.10

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?
I checked and didn't find similar issue
๐Ÿข Have you read the Code of Conduct?
I have read the Code of Conduct

๐Ÿ› Bug Report: Creating collection and creating attribute gives error in the logs.

๐Ÿ‘Ÿ Reproduction steps
Creating collection and creating attribute(s)gives error in the logs. But it does create the collection.

    private var appwriteClient: Client = Client()
        .setEndpoint(APPWRITE_ENDPOINT)
        .setProject(APPWRITE_PROJECT)
        .setKey(APPWRITE_KEY)
        .setSelfSigned(false)
    val appwriteDatabase = Database(appwriteClient)
        
        val collection: Collection = appwriteDatabase.createCollection(
            collectionId = "TEST",
            name =  "TEST",
            read = ["team:xxx"],
            write = ["team:xxx"],
            permission = "collection"
            
            
        appwriteDatabaseTest.createEmailAttribute(collectionId = "TEST", key = "email", required = false)
    

๐Ÿ‘ Expected behavior
No error expected

๐Ÿ‘Ž Actual Behavior
Shows the following error in Appwrite:

[Error] Timestamp: 2022-01-30T23:39:16+00:00
[Error] Method: GET
[Error] URL: /v1/database/collections/:collectionId
[Error] Type: Utopia\Exception
[Error] Message: Collection not found
[Error] File: /usr/src/code/app/controllers/api/database.php
[Error] Line: 266

๐ŸŽฒ Appwrite version
Version 0.12.1

๐Ÿ’ป Operating system
Windows

๐Ÿงฑ Your Environment
Appwrite v0.12.1 - sdk-for-kotlin v0.2.5
Java v11
Kotlin v1.6.10

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?
I checked and didn't find similar issue
๐Ÿข Have you read the Code of Conduct?
I have read the Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.