Skip to content

crapthings/meldbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

117 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meldbase

Meldbase is a single-file document database for Go applications. Open a file, write documents, query them, and close it. When a browser or another process needs access, run the optional meld server in front of the same file.

It is an alpha project. It is a good fit for local development and single-node applications; do not use it for data you cannot afford to lose.

Start in two minutes

Install the CLI on macOS:

brew tap crapthings/tap
brew trust --tap crapthings/tap
brew install crapthings/tap/meldbase

Start a local database and HTTP server:

mkdir -p ./data
meld serve --db ./data/app.meld --dev-no-auth

The server listens on http://127.0.0.1:8080. In another terminal, check that it is ready:

curl http://127.0.0.1:8080/readyz

--dev-no-auth is intentionally for local development only. Do not expose that server to a network.

Embed it in Go

For the smallest setup, use the database directly from your Go process:

go get github.com/crapthings/meldbase@latest
package main

import (
	"context"
	"log"

	"github.com/crapthings/meldbase"
)

func main() {
	ctx := context.Background()
	db, err := meldbase.Open("app.meld")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	todos := db.Collection("todos")
	_, err = todos.InsertOne(ctx, meldbase.Document{
		"title": meldbase.String("Ship something"),
		"done":  meldbase.Bool(false),
	})
	if err != nil {
		log.Fatal(err)
	}
}

The app.meld file remains after the process exits. One writable process owns one database file at a time.

Choose a path

If you want to… Start here
Put durable documents in a Go application Five-minute Go tour
Use Meldbase from a browser Run meld serve, then read the Browser guide
Use Meldbase from another Node.js process Run meld serve, then read the Node.js guide

What it is — and is not

Meldbase gives one application a durable document file, typed queries, indexes, and live query updates. It can add an HTTP and WebSocket boundary when needed.

It is not a hosted database, a MongoDB-compatible service, or a distributed system. It does not provide automatic failover, sharding, or built-in user identity.

Next

For project contributors, see CONTRIBUTING.md. Security reports are covered by SECURITY.md.

License

Licensed under the Apache License 2.0.

About

Embedded reactive document database for Go and TypeScript — durable local files, typed queries, and live updates.

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages