hvuhsg / gomongo

Mongo like database writen in GO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gomongo

Mongo like database writen in GO


Go Bring Them Home

NOTE

This project is a work in progress

Install

go get github.com/hvuhsg/gomongo

Simple usage examples

package main

import (
	"fmt"

	"github.com/hvuhsg/gomongo/engine"
	"github.com/hvuhsg/gomongo/indexing"
	"github.com/hvuhsg/gomongo/storage/ram"
	"github.com/hvuhsg/gomongo/validation"
)

func main() {
	validator := validation.New()
	indexor := indexing.New()
	ramStorage := ram.New()
	dbEngine := engine.New(validator, indexor, ramStorage)

	dbEngine.CreateDatabase("db")
	dbEngine.CreateCollection("db", "col")

	documents := []map[string]any{{"a": 5}, {"a": 2.5}}
	dbEngine.Insert("db", "col", documents)

	filter := map[string]any{"a": map[string]any{"$gt": 2.5}}
	result, _ := dbEngine.Find("db", "col", filter)

	fmt.Println(result) // -> [map[a:5]]
}

About

Mongo like database writen in GO


Languages

Language:Go 100.0%