dantdb

package module
v0.0.0-...-3107bbc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 8 Imported by: 0

README

dantDB

A simple no-SQL database inspired by SQLite .

Features

  • Easy to Install as a library
  • Easy to use
  • Easy to visualize using JSON
  • safe DB access through mutex's

Installation

go get github.com/abhinav-TB/dantdb

Usage

package main

import (
	"fmt"
	"log"

	"github.com/abhinav-TB/dantdb"
)

type Student struct {
	Name   string
	RollNo int
}

func main() {
	dir := "./"

	db, err := dantdb.New(dir) // creates a new database
	if err != nil {
		log.Fatal(err)
	}

	db.Write("students", "John", Student{ // writes to the database
		Name:   "John",
		RollNo: 21,
	})

	record := Student{}

	err = db.Read("students", "John", &record)

	if err != nil { // reads from the database
		log.Fatal(err)
	}

	fmt.Println(record)

}

More examples can be found in the examples directory

Contribute

Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request
Top contributors
IlliaFox

License

MIT © Abhinav TB

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCollection = errors.New("missing collection")
	ErrNoResource   = errors.New("missing resource")
)

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func New

func New(dir string) (*Driver, error)

func (*Driver) DeleteCollection

func (d *Driver) DeleteCollection(collection string) error

func (*Driver) DeleteResource

func (d *Driver) DeleteResource(collection, resource string) error

func (*Driver) Read

func (d *Driver) Read(collection, resource string, v any) error

func (*Driver) ReadAll

func (d *Driver) ReadAll(collection string) ([]string, error)

func (*Driver) Write

func (d *Driver) Write(collection, resource string, v any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL