Skip to content

Basic Operations

roseduan edited this page Jun 18, 2022 · 3 revisions

Basic Operations

Basic operations for RoseDB.

Open a database

package main

import (
	"fmt"
	"github.com/flower-corp/rosedb"
	"path/filepath"
)

func main() {
	path := filepath.Join("/tmp", "rosedb")
	// specify other options
	// opts.XXX
	opts := rosedb.DefaultOptions(path)
	db, err := rosedb.Open(opts)
	if err != nil {
		fmt.Printf("open rosedb err: %v", err)
		return
	}
	defer func() {
		_ = db.Close()
	}()
}

You must specify a file path to open rosedb.

And you can set other options by otps.XXX.

Clone this wiki locally