Skip to content
forked from ostafen/clover

A lightweight document-oriented NoSQL database written in pure Golang.

License

Notifications You must be signed in to change notification settings

regmicmahesh/clover

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CloverDB 🍀

codecov Go Reference Go Report Card

CloverDB is a lightweight NoSQL database designed for being simple and easily maintainable, thanks to its small code base. It has been inspired by tinyDB.

Features

  • Document oriented
  • Written in pure Golang
  • Simple and intuitive api
  • Easily maintainable

API usage

import (
	"log"
	c "github.com/ostafen/clover"
)

...

Create a new collection

db, _ := c.Open("clover-db")
db.CreateCollection("myCollection")

doc := c.NewDocument()
doc.Set("hello", "clover!")

docId, _ := db.InsertOne("myCollection", doc)

doc = db.Query("myCollection").FindById(docId)
log.Println(doc.Get("hello"))

Query an existing database

db, _ := c.Open("../test-data/todos")

// find all completed todos belonging to users with id 5 and 8
q := db.Query("todos").Where(c.Field("completed").Eq(true).And(c.Field("userId").In(5, 8)))

todo := &struct {
    Completed bool   `json:"completed"`
    Title     string `json:"title"`
    UserId    int    `json:"userId"`
}{}

for _, doc := range q.FindAll() {
    doc.Unmarshal(todo)
    log.Println(todo)
}

Update and delete documents

db, _ := c.Open("../test-data/todos")

// mark all todos belonging to user with id 1 as completed
updates := make(map[string]interface{})
updates["completed"] = true

db.Query("todos").Where(c.Field("userId").Eq(1)).Update(updates)

// delete all todos belonging to users with id 5 and 8
db.Query("todos").Where(c.Field("userId").In(5,8)).Delete()

Contributing

CloverDB is still under development. Any contribution, in the form of a suggestion, bug report or pull request, is well accepted 😊

About

A lightweight document-oriented NoSQL database written in pure Golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%