All Projects → workshop-depot → dockage

workshop-depot / dockage

Licence: Apache-2.0, Apache-2.0 licenses found Licenses found Apache-2.0 LICENSE Apache-2.0 LICENSE_badger
embedded document/json store

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to dockage

Xodus
Transactional schema-less embedded database used by JetBrains YouTrack and JetBrains Hub.
Stars: ✭ 864 (+4220%)
Mutual labels:  nosql, embedded-database
Litedb.fsharp
Advanced F# Support for LiteDB, an embedded NoSql database for .NET with type-safe query expression through F# quotations
Stars: ✭ 147 (+635%)
Mutual labels:  nosql, embedded-database
Cog
A Persistent Embedded Graph Database for Python
Stars: ✭ 90 (+350%)
Mutual labels:  nosql, embedded-database
python-lsm-db
Python bindings for the SQLite4 LSM database.
Stars: ✭ 115 (+475%)
Mutual labels:  nosql, embedded-database
Ejdb
🏂 EJDB 2.0 — Embeddable JSON Database engine C library. Simple XPath like query language (JQL). Websockets / Android / iOS / React Native / Flutter / Java / Dart / Node.js bindings. Docker image.
Stars: ✭ 1,187 (+5835%)
Mutual labels:  embedded, nosql
Unqlite Python
Python bindings for the UnQLite embedded NoSQL database
Stars: ✭ 321 (+1505%)
Mutual labels:  nosql, embedded-database
Vedis Python
Python bindings for the Vedis embedded NoSQL database
Stars: ✭ 106 (+430%)
Mutual labels:  nosql, embedded-database
Libfpta
Ultra fast, compact, Embedded Database for tabular and semistructured data.
Stars: ✭ 100 (+400%)
Mutual labels:  nosql, embedded-database
Couchbase Lite C
C language bindings for the Couchbase Lite embedded NoSQL database engine
Stars: ✭ 58 (+190%)
Mutual labels:  embedded, nosql
Kitdb
KitDB是一个内嵌式持久型的 高速NoSQL存储 lib
Stars: ✭ 439 (+2095%)
Mutual labels:  embedded, nosql
sophy
Fast Python bindings to Sophia Database
Stars: ✭ 77 (+285%)
Mutual labels:  nosql, embedded-database
Couchbase Lite Core
Cross-platform C++ core library for Couchbase Lite
Stars: ✭ 187 (+835%)
Mutual labels:  embedded, nosql
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (+50%)
Mutual labels:  nosql, embedded-database
Nitrite Java
Java embedded nosql document store
Stars: ✭ 538 (+2590%)
Mutual labels:  nosql, embedded-database
Dbreeze
C# .NET MONO NOSQL ( key value store embedded ) ACID multi-paradigm database management system.
Stars: ✭ 383 (+1815%)
Mutual labels:  embedded, nosql
Unqlite
An Embedded NoSQL, Transactional Database Engine
Stars: ✭ 1,583 (+7815%)
Mutual labels:  embedded, nosql
AloeDB
Light, Embeddable, NoSQL database for Deno 🦕
Stars: ✭ 111 (+455%)
Mutual labels:  nosql, embedded-database
zephyr-rtos-tutorial
Zephyr tutorial for beginners
Stars: ✭ 94 (+370%)
Mutual labels:  embedded
fuerte
Low Level C++ Driver for ArangoDB
Stars: ✭ 41 (+105%)
Mutual labels:  nosql
libe4
C library of Teserakt's E4 end-to-end security protocol
Stars: ✭ 15 (-25%)
Mutual labels:  embedded

Go Report Card GoDoc

dockage

This is an embedded document/json store based on badger key-value store.

word

  • Document id must be database-wide unique. There is no notion of grouping documents (tables, collections, buckets, etc).
  • id and rev are mandatory fields that must be present inside document json.

put document

First, make sure to close the db when it is no longer needed:

db := createDB()
defer db.Close()

Database operations are safe to be done concurrently. In fact it is a characteristic of badger that writes will get a performance boost when done concurrently.

Define a struct that has id and rev json tags. These two fields are not optional.

type post struct {
    ID   string    `json:"id"`
    Rev  string    `json:"rev"`
    By   string    `json:"by,omitempty"`
    Text string    `json:"text,omitempty"`
    At   time.Time `json:"at,omitempty"`
    Tags []string  `json:"tags,omitempty"`
}

Now to put a post document inside the database:

p := &post{
    ID:   "POST:001",
    By:   "Frodo Baggins",
    Text: "Awesome blog post!",
    At:   time.Now(),
    Tags: []string{"golang", "nosql"},
}

db.Put(p)

get document

Documents can be read from database, using their id.

var result []post
db.Get(&result, "POST:001")

delete document

Deleting documents is also done using their id.

db.Delete("POST:001")

Do not set the field with rev tag. It is used for optimistic concurrency and is filled automatically by Put() method.

query posts by day

Queries can be performed using Views, which are predefined queries. Queries must be defined right after opening the database.

This View emits the day of posts:

db.AddView(NewView("time-day",
	func(em Emitter, id string, doc interface{}) {
		c, ok := doc.(*post)
		if !ok {
			return
		}
		em.Emit([]byte(c.At.Format("2006-01-02")), nil)
		return
	}))

View functions will be executed after put operations, inside the same write transaction, right before commit. So the Views are also consistent. An Emitter, the id of the document and the document itself is passed to View function. time-day is a View that only indexes posts and ignores other type of documents.

Now we can query this view:

db.Query(Q{View: "time-day", Start: []byte("2018-05-20"), End: []byte("2018-05-30")})

Queries return the document id (view key) and other stuff generated by the view. For querying all documents, leave View field empty.

query posts by tag

Nice thing about views is that it is possible to index and query nested structs.

Let's define a view that allows us to query posts based on their tags:

db.AddView(NewView("tags",
	func(em Emitter, id string, doc interface{}) {
		c, ok := doc.(*post)
		if !ok {
			return
		}
		for _, v := range c.Tags {
			em.Emit([]byte(v), nil)
		}
		return
    }))

Here Emit() method is called multiple times, for each tag.

To query and find posts that are tagged with golang:

db.Query(Q{View: "tags", Start: []byte("golang"), Prefix: []byte("golang")})

Prefix is set because we do not need tags greater than golang - like gozoo!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].