{"id":18320978,"url":"https://github.com/1407arjun/dbkong","last_synced_at":"2025-04-05T22:32:12.736Z","repository":{"id":46917783,"uuid":"406661776","full_name":"1407arjun/DBKong","owner":"1407arjun","description":"Test any type of cloud database on Android apps. No need of a dedicated backend.","archived":false,"fork":false,"pushed_at":"2021-09-27T07:28:09.000Z","size":52704,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T13:12:59.678Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/1407arjun/DBKong/packages/1005285","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1407arjun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-15T07:46:03.000Z","updated_at":"2022-05-09T21:12:01.000Z","dependencies_parsed_at":"2022-08-29T22:30:42.420Z","dependency_job_id":null,"html_url":"https://github.com/1407arjun/DBKong","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1407arjun%2FDBKong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1407arjun%2FDBKong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1407arjun%2FDBKong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1407arjun%2FDBKong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1407arjun","download_url":"https://codeload.github.com/1407arjun/DBKong/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411238,"owners_count":20934650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T18:18:02.395Z","updated_at":"2025-04-05T22:32:10.244Z","avatar_url":"https://github.com/1407arjun.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## DB Kong - Database connections simplified\n[![Android CI](https://github.com/1407arjun/DBKong/actions/workflows/android.yml/badge.svg)](https://github.com/1407arjun/DBKong/actions/workflows/android.yml)\n[![Gradle Package](https://github.com/1407arjun/DBKong/actions/workflows/gradle-publish.yml/badge.svg)](https://github.com/1407arjun/DBKong/actions/workflows/gradle-publish.yml)\n\nDB Kong is an Android library that allows you to connect, interact and test any type of cloud database on Android apps without the need to setup a dedicated backend. \nThe library simplifies the process of connecting to a database and performing operations on it to just a few lines of code. \n\nAs of the current release DB Kong supports the following databases (future releases are aimed at including many more):\n- `MongoDB`\n\nI really can't wait for y'all to try it out, so let's dive into the setup and features!\n\n- [Getting started](#getting-started)\n- [Using the library](#using-the-library)\n- [Contributing](#contributing)\n- [Acknowledgements](#acknowledgements)\n\n### Getting started\n1. Firstly add the dependencies to your `app/build.gradle` (module level gradle file):\n```\n...\n\ndependencies {\n\n    ...\n\n    implementation 'com.1407arjun.libs:dbkong:1.1.0'\n\n    //Volley dependencies (required by the library as of the current version)\n    implementation 'com.google.code.gson:gson:2.8.2'\n    implementation 'com.android.volley:volley:1.2.0'\n    \n    ...\n}\n```\n2. Create a `github.properties` file in the root of your project and add in the code as follows (skip this step if you want to use system environment variables as in step 2):\n``` \ngpr.usr = \u003c your github username \u003e\ngpr.key = \u003c your personal access token \u003e\n```\n**The personal access token should have read packages scope.**\n\n3. In the `app/build.gradle` (module level gradle file) include the following code to access the credentials from the `github.properties` file:\n```\n...\n\nandroid {\n\n  ...\n  \n  repositories {\n        maven {\n            url = \"https://maven.pkg.github.com/1407arjun/DBKong\"\n            credentials {\n                def githubProperties = new Properties()\n                githubProperties.load(new FileInputStream(rootProject.file(\"github.properties\")))\n\n                username = githubProperties['gpr.usr'] ?: System.getenv(\"GPR_USER\")\n                password = githubProperties['gpr.key'] ?: System.getenv(\"GPR_API_KEY\")\n            }\n        }\n    }\n    \n    ...\n}\n```\n\nSteps 2 and 3 are required by github to access any package published on **Github Packages**.\n\n4. Finally the repositories to your project level `build.gradle` file (depends on the Gradle version, **do not add these to the** `buildscript`):\n```\n...\n\nallprojects {\n    repositories {\n        google()\n        mavenCentral()\n    }\n}\n\n...\n```\n5. Sync the project with the build files.\n\n6. Add the permission to access the internet and allow clear-text traffic in the `AndroidManifest.xml`:\n```XML\n...\n\n  \u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e\n\n  ...\n\n  \u003capplication\n          android:usesCleartextTraffic=\"true\"\n\n          ...\n\n  \u003c/application\u003e   \n\n...\n```\n\n### Using the library\n1. Firstly initialize the library in the `onCreate()` of your `MainActivity.java` or any other Java file:\n```Java\n        new DBKong(getApplicationContext(), timeout, new OnInitListener() {\n            @Override\n            public void onInit(boolean init, Error error) {\n                if (init \u0026\u0026 error == null) {\n                \n                    ...\n    \n                } else {\n                    if (error != null)\n                    \n                        ...\n                }\n            }\n        });\n```\nHere, `timeout` is the time in **milliseconds** within which the connection should be established. You can set any timeout value depending on your use-case. On initialization, this\nmethod invokes a callback giving a `boolean` for the initialization status and an `Error` object for any error encountered (if any).\n\n2. If there is no error and the initialization status `init == true` then the intermediate server connection has been established and now all the connections to the database can be \nexecuted. Here, an example is shown for the MongoDB database:\n```Java\n  ...\n  \n        new DBKong(getApplicationContext(), timeout, new OnInitListener() {\n            @Override\n            public void onInit(boolean init, Error error) {\n                if (init \u0026\u0026 error == null) {\n                    String uri = \"mongodb+srv://admin:\u003cpassword\u003e@\u003ccluster_name\u003e.1oqwt.mongodb.net/\u003cdatabase_name\u003e?retryWrites=true\u0026w=majority\";\n                    MongoDBConnect.getInstance(uri, db, collection)\n                            .insertOne(query)\n                            .addOnSuccessListener(new OnSuccessListener() {\n                                @Override\n                                public void onSuccess(JSONObject response) {\n                                    \n                                    ...\n                                }\n\n                                @Override\n                                public void onFailure(Error error) {\n                                    \n                                    ...\n                                }\n                            });\n                }\n                \n                ...\n            }\n            \n        });\n        \n  ...         \n```\nHere, `uri` is the connection string of MongoDB, `db` and `collection` is the name of the database (string) and collection (string) you want to connect to. This instance has several \nmethods which you can use to perform CRUD or interact with the collection (for eg. `insertOne()`, `find()`, `deleteMany()`, etc.). Also you can add an `OnSuccessListener` callback to know if the operation\nis a success or whether it encountered an error, since all these tasks are carried out asynchronously.\n\n### Contributing\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.\n1. Fork the project. `git clone https://github.com/1407arjun/DBKong.git`\n2. Create your feature branch. `git checkout -b feature/AmazingFeature`\n3. Commit your changes. `git commit -m 'Add some AmazingFeature'`\n4. Push to the branch. `git push origin feature/AmazingFeature`\n5. Open a **Pull Request**.\n\n### Acknowledgements\n1. https://github.com/JaneaSystems/nodejs-mobile\n2. https://github.com/google/volley\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1407arjun%2Fdbkong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1407arjun%2Fdbkong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1407arjun%2Fdbkong/lists"}