gled

package module
v0.0.0-...-b17ee77 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 8 Imported by: 0

README

GLED

Lightweight Embedded Database in Golang, inspired by SQLite and PostgreSQL.

Usage

package main

import (
	"fmt"
	"github.com/luminocean/gled"
	"github.com/luminocean/gled/exp"
)

type Book struct {
	Name  string
	Count int
}

func main() {
	// table files will be created under "."
	db := gled.NewGleDB(".")

	// create a new table for books
	table, _ := gled.Table[Book](db, "basic")
	defer table.Close()

	// insert one
	_ = table.Insert(Book{
		Name:  "mybook",
		Count: 10,
	})

	// select
	books, _, _ := table.Select(exp.AndEx{
		Exps: []exp.Ex{
			exp.C("Name").Eq("mybook"),
			exp.C("Count").Gte(5),
		},
	})

	// gives "[{mybook 10}]"
	fmt.Println(books)
}

Roadmap

  • Multi-page support for Gled tables (currently only one page per table)
  • Multi-table/multi-database support
  • Indexing
  • SQL interface
  • DB Vacuum

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GledDB

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

func NewGleDB

func NewGleDB(directory string) *GledDB

type GledTable

type GledTable[T any] struct {
	// contains filtered or unexported fields
}

func Table

func Table[T any](db *GledDB, name string) (table *GledTable[T], err error)

func (*GledTable[T]) Close

func (t *GledTable[T]) Close() (err error)

func (*GledTable[T]) Delete

func (t *GledTable[T]) Delete(loc storage.TupleLocation) (err error)

func (*GledTable[T]) Insert

func (t *GledTable[T]) Insert(item T) (err error)

func (*GledTable[T]) Select

func (t *GledTable[T]) Select(ex exp.Ex) (items []T, locations []storage.TupleLocation, err error)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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