|
1 | 1 |
|
2 | | -# CloremDB ~ Key-value pair store |
3 | | -<p align="left"> |
4 | | - <a href="#"><img alt="Version" src="https://img.shields.io/badge/Language-Java-1DA1F2?style=flat-square&logo=java"></a> |
5 | | - <a href="https://www.instagram.com/x__coder__x/"><img alt="Instagram - x__coder__" src="https://img.shields.io/badge/Instagram-x____coder____x-lightgrey"></a> |
6 | | - <a href="#"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ErrorxCode/OTP-Verification-Api?style=social"></a> |
7 | | - </p> |
8 | 2 |
|
9 | | -CloremDB is a key-value paired nosql database written in JAVA for programs in JAVA. The data is stored like a JSON tree with nodes and children. It has |
10 | | -the most powerful query engine. You can perform low-level and high-level queries on database to sort data. Given a node, you can reach/find any node to any nested levels that are under it and can sort them on the basis of a property. |
| 3 | +<h1 align="center"> |
| 4 | + <br> |
| 5 | + <a href="http://www.amitmerchant.com/electron-markdownify"><img src="https://github.com/Clorabase/CloremDB/blob/main/image.png?raw=true" alt="Markdownify" width="300"></a> |
| 6 | + <br> |
| 7 | + CloremDB |
| 8 | + <br> |
| 9 | +</h1> |
11 | 10 |
|
12 | | - |
| 11 | +<h4 align="center">A child's play NO-SQL database for java aaps</h4> |
13 | 12 |
|
| 13 | +<p align="center"> |
| 14 | + <img src="https://img.shields.io/badge/Version-1.0-green?style=for-the-badge"> |
| 15 | + <img src="https://img.shields.io/github/license/ErrorxCode/CloremDB?style=for-the-badge"> |
| 16 | + <img src="https://img.shields.io/github/stars/ErrorxCode/CloremDB?style=for-the-badge"> |
| 17 | + <img src="https://img.shields.io/github/issues/ErrorxCode/CloremDB?color=red&style=for-the-badge"> |
| 18 | + <img src="https://img.shields.io/github/forks/ErrorxCode/CloremDB?color=teal&style=for-the-badge"> |
| 19 | +</p> |
14 | 20 |
|
15 | | -## Features |
| 21 | +<p align="center"> |
| 22 | + <img src="https://img.shields.io/badge/Author-Rahil--Khan-cyan?style=flat-square"> |
| 23 | + <img src="https://img.shields.io/badge/Open%20Source-Yes-cyan?style=flat-square"> |
| 24 | + <img src="https://img.shields.io/badge/Written%20In-Java-cyan?style=flat-square"> |
| 25 | +</p> |
16 | 26 |
|
17 | | -- Easy,lightweight and fast |
18 | | -- Data sorting using queries |
19 | | -- Direct object deserialization |
20 | | -- Capable of storing almost all primitive datatypes |
21 | | -- Use JSON structure for storing data |
22 | | -- Supports List<Integer> & List<String> |
| 27 | +<p align="center"> |
| 28 | + <a href="#key-features">Key Features</a> • |
| 29 | + <a href="#Usage">How To Use</a> • |
| 30 | + <a href="#Implimentation">Implimentation</a> |
| 31 | +</p> |
23 | 32 |
|
24 | | - |
25 | | -## Acknowledgements |
26 | | - - [What is No-Sql](https://en.wikipedia.org/wiki/Key%E2%80%93value_database) |
27 | | - |
28 | | -## Documentation |
29 | | -- [Javadocs](https://errorxcode.github.io/docs/clorem/index.html) |
30 | | -- [Guide](https://github.com/ErrorxCode/CloremDB/wiki/Guide) |
| 33 | +<img src="https://github.com/Clorabase/CloremDB/blob/main/clorem%20banner.png?raw=true" alt="Markdownify" width="1000"> |
31 | 34 |
|
32 | | - |
33 | | -## Deployment / Installation |
34 | | - In your project build.gradle |
35 | | -```groovy |
36 | | - allprojects { |
| 35 | +CloremDB is a simple, robust and easy to use embedded NO-SQL database for java applications. The data is directly saved as objects in the database. You can directly put POJO's in the database and can organize them is different volume. Each volume is like a SQL table which contains objects (as rows). You can have unlimited number of volumes and objects in it. |
| 36 | + |
| 37 | +*I bet you will not find database easier and powerful than this* |
| 38 | + |
| 39 | +## 🎯Key Features |
| 40 | + |
| 41 | +* Super simple, made using the most simple design ever |
| 42 | +* Moders query, No query builder. Predicates are used rather. |
| 43 | +* Can directly cache objects (POJO's) |
| 44 | + |
| 45 | +## 💉Implimentation |
| 46 | +[](https://jitpack.io/#ErrorxCode/Clorine) |
| 47 | +### Gradle :- |
| 48 | +Add it in your root build.gradle at the end of repositories: |
| 49 | + |
| 50 | +```css |
| 51 | + allprojects { |
37 | 52 | repositories { |
38 | 53 | ... |
39 | 54 | maven { url 'https://jitpack.io' } |
40 | 55 | } |
41 | 56 | } |
42 | 57 | ``` |
43 | | -In your app build.gradle |
44 | | -```groovy |
45 | | -dependencies { |
| 58 | + |
| 59 | +**Step 2.** Add the dependency |
| 60 | + |
| 61 | +```css |
| 62 | + dependencies { |
46 | 63 | implementation 'com.github.ErrorxCode:CloremDB:Tag' |
47 | 64 | } |
48 | 65 | ``` |
49 | | -[](https://jitpack.io/#ErrorxCode/CloremDB) |
50 | 66 |
|
| 67 | +### Maven :- |
| 68 | +**Step 1**. Add to project level file |
| 69 | +```markup |
| 70 | + <repositories> |
| 71 | + <repository> |
| 72 | + <id>jitpack.io</id> |
| 73 | + <url>https://jitpack.io</url> |
| 74 | + </repository> |
| 75 | + </repositories> |
| 76 | +``` |
| 77 | + |
| 78 | +**Step 2.** Add the dependency |
51 | 79 |
|
52 | | -## It's easy |
| 80 | +```markup |
| 81 | + <dependency> |
| 82 | + <groupId>com.github.ErrorxCode</groupId> |
| 83 | + <artifactId>CloremDB</artifactId> |
| 84 | + <version>Tag</version> |
| 85 | + </dependency> |
53 | 86 | ``` |
54 | | -Clorem.getInstance().addMyData().commit(); |
| 87 | + |
| 88 | +## 📃Documentation |
| 89 | +After this guide, I guarantee, you will never be required to see the documentation of this database. This guide will explain everything step-by-step with examples. So let's begin with the index. |
| 90 | + |
| 91 | +It would be best if you see [JavaDocs](https://errorxcode.github.io/docs/clorem/index.html) and acknowledgment first before diving into the guide. Anyway, let's get started. |
| 92 | + |
| 93 | +### Initialization |
| 94 | +First of all, you need to implement `CloremObject` interface in the every class of which you wanna save data in the database. |
| 95 | +**For example**: |
| 96 | +```java |
| 97 | +class User implements CloremObject{ |
| 98 | + public String name; |
| 99 | + public String password; |
| 100 | + public String id; |
| 101 | + |
| 102 | + public User(String id,String name, String password) { |
| 103 | + this.name = name; |
| 104 | + this.password = password; |
| 105 | + this.id = id; |
| 106 | + } |
| 107 | + |
| 108 | + @Override |
| 109 | + public String getKey() { |
| 110 | + return id; |
| 111 | + } |
| 112 | + |
| 113 | + @Override |
| 114 | + public String getVolume() { |
| 115 | + return "demoVolume"; |
| 116 | + } |
| 117 | + |
| 118 | + @Override |
| 119 | + public String toString() { |
| 120 | + return "User{" + |
| 121 | + "name='" + name + '\'' + |
| 122 | + ", password='" + password + '\'' + |
| 123 | + ", id='" + id + '\'' + |
| 124 | + '}'; |
| 125 | + } |
| 126 | +} |
| 127 | +``` |
| 128 | +then initialize the database as like this, |
| 129 | +```java |
| 130 | +Clorem db = Clorem.getInstance(databaseDir); |
| 131 | +``` |
| 132 | +After that, for the first time, you need to create volume. Volume is like SQL table in which your object will be stored. |
| 133 | +```java |
| 134 | +db.createVolume("demoVolume"); |
| 135 | +``` |
| 136 | +Your object class must return the **Volume name** in which the object will be saved. |
| 137 | + |
| 138 | + |
| 139 | +### Putting data |
| 140 | +Putting data is very simple. You just need to implement `CloremOBject` in you POJO to save it in database. |
| 141 | +```java |
| 142 | +db.put(new User("xyz","rahil","123")); |
| 143 | +db.put(new User("key","nandan","any")); |
| 144 | +db.put(new User("x0x","tabish","asdf")); |
55 | 145 | ``` |
56 | | - |
57 | | - |
58 | 146 |
|
59 | | -## Powered by ❤ |
60 | | -#### [Clorabase](https://clorabase.netlify.app) |
61 | | -> A account-less platform as a service for android apps. (PaaS) |
| 147 | +### Fetching data |
| 148 | +Just use `get()` method passing the key of the object you wish to rertrive. You need to cast it to the desired class manually. |
| 149 | +```java |
| 150 | +User obj = (User) db.get("xyz","demoVolume"); |
| 151 | +System.out.println(obj.name); // prints 'rahil' |
| 152 | +``` |
| 153 | + |
| 154 | +### Updating data |
| 155 | +There are two ways of updating an object. One for updating/overwriting whole object and another one for updating only required field. |
| 156 | + |
| 157 | +**To overwrite whole object**: |
| 158 | +```java |
| 159 | +db.update(new User("xyz", "rahil", "khan")); |
| 160 | +``` |
| 161 | +where, "xyz" is the key of the object I want to update. **That must be unchanged** |
| 162 | + |
| 163 | +**To update required fields**: |
| 164 | +```java |
| 165 | +db.update("xyz", "demoVolume", User.class, user -> { |
| 166 | + user.id = "abc"; |
| 167 | + user.name = "Rahil"; |
| 168 | +}); |
| 169 | +``` |
| 170 | +This will only update the changes you have made to `user` object. |
| 171 | + |
| 172 | + |
| 173 | +### Deleting data/objects |
| 174 | +To delete any object, simply call `delete(key,volume)` method. To delete whole volume, use `deleteVolume(name)` |
| 175 | +```java |
| 176 | +db.delete("xyz", "demoVolume"); |
| 177 | +db.deleteVolume("demoVolume"); |
| 178 | +``` |
| 179 | + |
| 180 | +### Querying data |
| 181 | +CloremDB has the most easy querying compared to any other database. You just need to pass a `Predicate` to a function which specify the condition you want to query for. The query will inclue the object for every `test(Object)` (your predicate function) returning true. |
| 182 | + |
| 183 | +For example, I want to get users whose name contains 'a'. |
| 184 | +```java |
| 185 | +List<User> list = db.query("demoVolume", User.class, user -> user.name.contains("a")); |
| 186 | +``` |
| 187 | + |
| 188 | +Here is how it works, |
| 189 | +```java |
| 190 | +List<User> list = db.query("demoVolume", User.class, new Predicate<User>() { |
| 191 | + @Override |
| 192 | + public boolean test(User user) { |
| 193 | + // check the object, if it meets your condition |
| 194 | + // then return true, otherwise false |
| 195 | + return user.name.equals("rahil"); |
| 196 | + } |
| 197 | +}); |
| 198 | +``` |
| 199 | + |
| 200 | +***That's all what you need to learn about this database :)*** |
| 201 | + |
| 202 | + |
| 203 | +## 🆘Support |
| 204 | + |
| 205 | +If you like my work then you can suppot me by giving this repo a ⭐. You can check my other repos as well, if you found this library userfull then you will definetly fine more in my profiles. |
| 206 | + |
| 207 | +## You may also like... |
| 208 | + |
| 209 | +- [ClorastoreDB](https://github.com/Clorabase/ClorastoreDB) - A mongoDB/firestore database offline version |
| 210 | +- [ClorographDB](https://github.com/amitmerchant1990/correo) - CLorabase offline graph database |
| 211 | + |
| 212 | + |
| 213 | +## Powered by 💓 |
| 214 | +#### [Clorabase](https://github.com/clorabase) |
| 215 | +> A account less backend for android |
0 commit comments