Skip to content
Lenny edited this page Oct 18, 2023 · 8 revisions

Polygon Database

What is Polygon DB?

PolygonDB is a cutting-edge database management system meticulously crafted to draw inspiration from MongoDB's design principles while offering a more ease of use and flexibiltiy when working with the DB.

Installing PolygonDB

Local (On Your PC / Device) - Recommended for Developers

  1. Install Tools Needed:
  1. Clone / Download the Code Download the Zip (or git clone) the code. If you are downloading via zip, extract the files onto a folder.

  2. Build it Use the command cargo build --release, this would compile the code into a .exe (or file appropriate to your CPU architecture / OS)

Using Polygon

Polygon uses CRUD. Create, Read, Update, Delete are the four basic operations of persistent storage.

  • Create
  • Read
  • Update
  • Delete

Example Json Database

{
	"rows": [
		{
			"age": 5,
			"name": "A"
		},
		{
			"age": 20,
			"name": "B"
		},
		{
			"age": 30,
			"name": "C"
		},
		{
			"age": 40,
			"name": "D"
		}

}

Create

Create goes to a certain area and records whatever is in value onto the json.

    {
        'dbname': 'name_of_database',
        'location' :'/location/of/data',
        'action' : 'create',
        'value':'value_of_choice' 
    }

Example.

    {
        'dbname': 'CatoDB',
        'location' :'/rows',
        'action' : 'create',
        'value': {"age": 13,"name": "DE"} #this will add the entire value onto the array
    }

Read

Read will retrieve the value in the json

    {
        'dbname': 'name_of_database',
        'location' :'location_in_json',
        'action' : 'read',
        'value' : _ #can be ignored
    }

Example.

#This goes into the rows (which is an array) and gets the first data and gets name (which is object)
    {
        'dbname': 'CatoDB',
        'location' :'/rows/0/name',
        'action' : 'read'
       'value' : _ #can be ignored
    } #output is "A"

Update

Update will update pre-existing variables. While create and update can be use the same, update is more cpu resource friendly and will update a previously-existing variable

    {
        'dbname': 'name_of_database',
        'location' :'location_in_json', # <- Location that you are searching through
        'action' : 'update',
        'value':'value'
    }
    {
        'password': 'Better_Password', 
        'dbname': 'CatoDB',
        'location' :'rows/1/age', #The area we are searching in is rows
        'action' : 'update',
        'value':'30' 
    } #Updates the 1-index of the array age to 30

Delete

Deletes data from JSON

    {
        'dbname': 'name_of_database',
        'location' :'location_in_json', 
        'action' : 'delete',
        'value':_
    }

Example.

    {
        'password': 'Better_Password', 
        'dbname': 'CatoDB',
        'location' :'rows/3',
        'action' : 'delete',
        'value': _
    } #Deletes the 3-index of the array

Terminal

Polygon has a built-in terminal that helps make things easier.

====Polygon Terminal====
CREATE_DATABASE "name"                          This will create a database for you with name and password
========================

It helps make certain tasks easier.