TanmoySG / wunderDB

A micro JSON-based Data Store inspired by MongoDB.
http://wdb.tanmoysg.com/api/
Apache License 2.0
13 stars 0 forks source link

📜 Proposal for WDB-Archipelago - v2.0 #6

Closed TanmoySG closed 1 year ago

TanmoySG commented 2 years ago

WDB-Archipelago

WunderDB v2.0, named "Archipelago", aims at making wdb code more maintainable and mature. This Proposal Issue will act as a place to put ideas for the v2.0. The main goal of v2.0 proposal should primarily encompass, but not limited to

TanmoySG commented 2 years ago

https://stackoverflow.com/questions/25896322/how-can-i-create-a-separate-namespace-within-a-python-script

TanmoySG commented 2 years ago

Development Maturity

TanmoySG commented 2 years ago

Code Modularity

TanmoySG commented 2 years ago

Code Maturity

TanmoySG commented 2 years ago

Schema

Currently the schemas are defined as fieldName : description and doesn't handle data-type, constraints. In v2,

TanmoySG commented 2 years ago

Data

TanmoySG commented 2 years ago

Storage

Sample Directory Structure

image
TanmoySG commented 2 years ago

File System

image image image image image image image
TanmoySG commented 2 years ago

Notes

TanmoySG commented 2 years ago

Notes

TanmoySG commented 1 year ago

Notes

TanmoySG commented 1 year ago

Notes

In program Data Structure (with sample data JSON), derived from this Directory tree.

{
    "namespaces": {
        "gns": {
            "alias": "",
            "id": "",
            "path": "",
            "databases": {
                "db-one": {
                    "name": "db1",
                    "collection": {
                        "coll-one": {
                            "name": "",
                            "path": "",
                            "data": {
                                "data": {
                                    "field-1": "true"
                                },
                                "path": ""
                            },
                            "metadata": {
                                "metadata": null,
                                "schema": null,
                                "path": ""
                            }
                        }
                    },
                    "metadata": {
                        "metadata": null,
                        "schema": null,
                        "path": ""
                    },
                    "path": ""
                }
            }
        }
    },
    "users": {}
}

Go Model on which this is based

package model

type FilePath string
type Identifier string

type User map[string]interface{}

type WDBFileSystem struct {
    Namespaces map[Identifier]Namespace `json:"namespaces"`
    Users      map[Identifier]User      `json:"users"`
}

type Namespace struct {
    NamespaceAlias string                  `json:"alias"`
    NamespaceID    Identifier              `json:"id"`
    NamespacePath  FilePath                `json:"path"`
    Databases      map[Identifier]Database `json:"databases"`
}

type Database struct {
    DatabaseName Identifier                `json:"name"`
    Collections  map[Identifier]Collection `json:"collection"`
    Metadata     Metadata                  `json:"metadata"`
    DatabasePath FilePath                  `json:"path"`
}

type Collection struct {
    CollectionName Identifier `json:"name"`
    CollectionPath FilePath   `json:"path"`
    Data           Datum      `json:"data"`
    Metadata       Metadata   `json:"metadata"`
}

type Datum struct {
    Data     map[Identifier]interface{} `json:"data"`
    DataPath FilePath                   `json:"path"`
}

type Metadata struct {
    Metadata     map[string]interface{} `json:"metadata"`
    Schema       map[string]interface{} `json:"schema"`
    MetadataPath FilePath               `json:"path"`
}
TanmoySG commented 1 year ago

Storing JSON Files to Persist Data

A minified JSON File is stored JSON Data without indentation. This results in a lesser sized data file. Here is a comparison.

Screenshot 2022-11-18 at 10 23 45 AM

So the release build of WDB should use minified JSON to persist data after shutdown.

TanmoySG commented 1 year ago

Notes

TanmoySG commented 1 year ago

Filters (replacement for Marker)

type Filter struct {
    Key   string      `json:"key"`
    Value interface{} `json:"value"`
    // Filter operator - < / greater , > / lesser , = / equal , != / unequal
    // Operator string      `json:"operator"` // Future scope
}
TanmoySG commented 1 year ago

https://mrkaran.dev/posts/barreldb/