Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanrichan/tinydb
TinyDB is a lightweight document oriented database optimized for your happiness :)
https://github.com/kanrichan/tinydb
database golang json nosql
Last synced: 3 months ago
JSON representation
TinyDB is a lightweight document oriented database optimized for your happiness :)
- Host: GitHub
- URL: https://github.com/kanrichan/tinydb
- Owner: kanrichan
- License: mit
- Created: 2021-10-30T12:56:05.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-19T04:19:53.000Z (over 1 year ago)
- Last Synced: 2024-10-31T21:35:13.043Z (3 months ago)
- Topics: database, golang, json, nosql
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 43
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinydb
### Introduction
[TinyDB](https://github.com/msiemens/tinydb) is a lightweight document oriented database optimized for your happiness :) The target are small apps that would be blown away by a SQL-DB or an external database server.
But in this project, it's written in pure Golang and has no external dependencies.
### Example Code
Import
```Go
import tiny "github.com/Yiwen-Chan/tinydb"
```New a storage
```Go
storage, err := tiny.JSONStorage("test.json")
```Open a database used by storage
```Go
database, err := tiny.TinyDB(storage)
defer database.Close()
```Get a table and Insert or Delete or Update or Select
```Go
table := tiny.GetTable[student](database)
table.Insert(student{001, "test"})
table.Update(func(s student) student { s.ID = 002; return s }, func(s student) bool { return true })
table.Select(func(s student) bool { return true })
table.Delete(func(s student) bool { return true })
```