Skip to content

Commit ae0a90a

Browse files
authored
Archive waterbase.md blog post
Archived the blog post as it is no longer relevant.
1 parent 3b4b368 commit ae0a90a

1 file changed

Lines changed: 1 addition & 79 deletions

File tree

src/content/post/waterbase.md

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,83 +3,5 @@ title: The Easiest Database you could ever need!
33
description: As a developer, you might have heard of FireBase. But do you know about.....WaterBase ??
44
date: 2022-08-02
55
---
6-
### As a developer, you might have heard of FireBase. But do you know about.....WaterBase ??
76

8-
I've always admired Android in the way of storing persistent data. If you are famaliar with Android Development, you'd know about Shared Preferences. If that's new to you, it is basically a storage utility that Android provides using which you can store data in Key-value form. Shared Preferences are suitable in different situations. For example, when the user’s settings need to be saved or to store data that can be used in different activities within the app.
9-
10-
But...we don't get that awesome feature outside the Android environment. Do we? So I decided to create a lightweight storage utility that provides such behavior and can be used on any platform. And voila...[WaterBase](https://github.com/coderGtm/WaterBase) was born ;)
11-
12-
![WaterBase](../../assets/images/posts/waterbase.png)
13-
14-
#### So first thing's first. Why the name ?
15-
16-
Ok...so here's my explanation. As we all know that 🔥FireBase is a database that is in cloud and can be accessed from anywhere. And so WaterBase is a database on your hard disk that can be accessed from anywhere...just like water🌊...simple and lightweight🪶.
17-
18-
![cool](https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExZ29rbG9iYWF3azdkZTYzZTlod3F1Y2JkZzhiY3JqbnJvZWZjZ3dpdCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/14xwAVBIYjCNhu/giphy.gif)
19-
20-
#### How it's used ?
21-
22-
As promised, in the easisest way...WaterBase is currently available in C++ and Python
23-
24-
> Talk is cheap. Show me the code.
25-
26-
Ok then...here's the Python version
27-
28-
```python
29-
from waterbase import WaterBase
30-
31-
# Create / open a database file (creates one if it doesn't exist)
32-
db = WaterBase("myDatabase")
33-
34-
# Save values (Bool / Int / String supported)
35-
db.SaveBool("is_active", True)
36-
db.SaveInt("score", 42)
37-
db.SaveString("username", "gautam")
38-
39-
# Load them back (second arg is default value if key missing)
40-
active = db.LoadBool("is_active", False)
41-
score = db.LoadInt("score", 0)
42-
username = db.LoadString("username", "guest")
43-
44-
print(active, score, username)
45-
```
46-
47-
And if you rather prefer C++, you're covered:
48-
49-
```cpp
50-
#include "WaterBase.hpp"
51-
#include <iostream>
52-
53-
int main() {
54-
WaterBase db("myDatabase");
55-
56-
db.SaveBool("is_active", true);
57-
db.SaveInt("score", 42);
58-
db.SaveString("username", "gautam");
59-
60-
bool active = db.LoadBool("is_active", false);
61-
int score = db.LoadInt("score", 0);
62-
std::string user = db.LoadString("username", "guest");
63-
64-
std::cout << active << " " << score << " " << user << std::endl;
65-
return 0;
66-
}
67-
```
68-
69-
#### Explanation:
70-
71-
First we create an instance of the class WaterBase. We provide the name of the WaterBase database to use as parameter. If no database exists by that name, a new one is created.
72-
73-
Now let's put some values in our database. WaterBase supports three types of values: Boolean, Integer and String. To save values, use the `db.Save*(key, value)` function.
74-
75-
Now if you want to retreive these values, use `db.Load*(key, default_value)` function.
76-
77-
That's all...This is the simplest databse you could ever need. You can find the GitHub repository [here.](https://github.com/coderGtm/WaterBase)
78-
79-
And one last thing...if you've read till here and are still unsure whether should you use WaterBase or not in a project, then please, please, please drop a comment on the repository's [issue page](https://github.com/coderGtm/WaterBase/issues), describing why you don't wanna use it. It can help the community to make WaterBase a better product, more suited for you.
80-
81-
![goodbye](https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExaXFlOWh0bmlvNW1oNXUzNnJjYTM1emJmM28wYTNidHR0cXZ3M2VlMiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/zDpYQooxkwXkAWMxRK/giphy.gif)
82-
83-
Goodbye!!
84-
85-
coderGtm
7+
## This blog post has been archived and hidden as it is no longer relevant!

0 commit comments

Comments
 (0)