Skip to content

CborgDB/cborg-go-driver

Repository files navigation

CborgDB Go Driver

version Go Report Card Go Dependency

The CborgDB Go Driver is 🚧 still under development 🚧 and CborgDB also.

Requirements

Install

  • Download

go get github.com/cborgdb/cborg-go-driver

  • Import

import "github.com/cborgdb/cborg-go-driver/cborg"

Usage

  1. Run docker container
docker run -d -p 30000:30000 cborgdb/cborg:0.6.0
  1. Run the following sample code
package main

import (
	"os"

	"github.com/cborgdb/cborg-go-driver/cborg"
)

func main() {
	client := cborg.NewClient("127.0.0.1", "30000")
	err := client.Connect()
	if err != nil {
		os.Exit(1)
	}
	defer client.Disconnect()

	// Create Database
	result, _ := client.CreateDatabase("cborgdb")
	// Create Collection using previous result
	result.Database.CreateCollection("numbers")

	// Init "number" Collection
	numbers := client.Database("cborgdb").Collection("numbers")
	// Insert an item
	numbers.InsertOne(1992)
}

License

Copyright © 2022 Adil Benhlal

The CborgDB Go Driver is licensed under the Apache License.