DEV Community

Cover image for Introducing DBJson Document Database.
KetanIP
KetanIP

Posted on • Updated on

Introducing DBJson Document Database.

Hello guys today I am here to introduce my 🐶pet project DBJson. It is a Document Oriented Database.

This is a simple data base which stores its data in the form of collections and records format in JSON files!

Structure of data:

DON'T WORRY IT IS AUTOGENERATED.

This was made by me as sometimes I don't like to setup ORM or Databases for small projects that are never going to production ever.

So I though why not make a make a database for such thing only. I decided to make a NoSQL database as it can store any data without setting up tables as we need to do it with RDBMS.

At its current you can download/view it on Github also check out DBJson's docs here.

At its current stage it can do the following things:

  1. Creating records
  2. Reading records
  3. Updating records
  4. Deleting records
  5. Filter records

What are its inspiration ?

It has got its inspirations from tinyDB ( for its simplicity ) and Firestore( NOSQL database offered by firebase for its document style datamodelling ).

Getting Stated

Getting stated with it is damn easy,

from dbjson.main import DB

# Instatilizing DB class
db = DB()

# Test Data
data = {
  "id": 1,
  "first_name": "Vivyan",
  "last_name": "Treherne",
  "email": "vtreherne0@jigsy.com",
  "ip_address": "94.254.247.240"
}
collection = "users"

# Adding Record
data = db.createRecord(collection, data)
print(data)
# Response -> {'__id__': 'f00ae4e3ca8c3e318a68acc460e5f401', '__data__': {'id': 1, 'first_name': 'Vivyan', 'last_name': 'Treherne', 'email': 'vtreherne0@jigsy.com', 'ip_address': '94.254.247.240'}}

# Updating Record
record_key = "f00ae4e3ca8c3e318a68acc460e5f401"
to_update = [
    {"email": "jhon@email.com"},
    {"ip_address": "google.com"}
]
data = db.updateRecord(collection, "f00ae4e3ca8c3e318a68acc460e5f401", to_update)
print(data)
# Response -> {'id': 1, 'first_name': 'Vivyan', 'last_name': 'Treherne', 'email': 'jhon@email.com', 'ip_address': 'google.com'}

# Deleting Record
db.removeRecord(collection, record_key)
Enter fullscreen mode Exit fullscreen mode

That's all you need to generate use your db. This is still in its very early stage of development so it may be unstable and may be subjected to change, so if you want to follow it updates you can follow it on GitHub or you can follow me here on dev.to.

You can explore all its features at https://ketanip.github.io/dbjson/main.html.

Hope you guys like it. You can contribute it too at https://github.com/ketanip/dbjson/.

Top comments (7)

Collapse
 
fredysomy profile image
Fredy Somy

Great one..
I also have built a similar one .. give a look..
PysonDB

Collapse
 
ketanip profile image
KetanIP

It's amazing, loved it. Can you please share how you created the documentation for it ( manually or automatically ) ?

Collapse
 
fredysomy profile image
Fredy Somy

Thank you...
It was all done manually ..

Thread Thread
 
ketanip profile image
KetanIP

Can you suggest some features to add in it ?

Thread Thread
 
fredysomy profile image
Fredy Somy

Are you in twiiter..just followed you.. we can talk there

Collapse
 
vivekkodira profile image
Vivek Kodira

Nice! There is a similar nodejs express repo called json-server (github.com/typicode/json-server). Sharing in case it helps you.

Collapse
 
ketanip profile image
KetanIP

Yes it is somewhat like it, and you have given me an idea that we can cover it in an API cover, so it could be used with any language.

Thanks for your response.