Skip to content
/ nun-db-go Public

A fan-made Go client for interacting with NunDB, a NoSQL database that supports real-time data synchronization and flexible data manipulation.

Notifications You must be signed in to change notification settings

kqnd/nun-db-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NunDB Golang Client

NunDB is a realtime key-value database written in Rust by @mateusfreira.
This repository provides a Golang client for interacting with a NunDB server.

For more details, check out the official NunDB repository.


Installation

go get github.com/kqnd/nun-db-go@v0.1.2

Basic Usage

package main

import (
    "fmt"
    nundb "github.com/kqnd/nun-db-go"
)

func main() {
    client, err := nundb.NewClient("ws://localhost:3012", "username", "password")
    if err != nil {
        panic(err)
    }

    // Create or use a database
    client.CreateDatabase("mydb", "mypass")
    client.UseDatabase("mydb", "mypass")

    // Set a value
    client.Set("foo", "bar")

    // Get a value
    val, _ := client.Get("foo")
    fmt.Println("foo:", val)

    // Watch for changes
    client.Watch("foo", func(v interface{}) {
        fmt.Println("foo changed:", v)
    })

    // Increment a numeric value
    client.Increment("counter", 1)
}

Features

  • Authentication (auth command)
  • Database management:
    • create-db
    • use-db
    • debug list-dbs
  • Key-value operations:
    • set
    • get
    • remove
    • increment
  • Key listing:
    • keys
    • Filter by prefix or suffix
  • Watchers:
    • watch
    • unwatch
    • unwatch-all

Example Commands

// Set and Get
client.Set("name", "Alice")
val, _ := client.Get("name")
fmt.Println(val) // Alice

// Remove key
client.Remove("name")

// Get all keys
keys, _ := client.GetAllKeys()
fmt.Println(keys)

// Get keys starting with "user:"
keys, _ := client.GetKeysStartingWith("user:")

// Get keys ending with ":id"
keys, _ := client.GetKeysEndingWith(":id")

License

MIT

About

A fan-made Go client for interacting with NunDB, a NoSQL database that supports real-time data synchronization and flexible data manipulation.

Topics

Resources

Stars

Watchers

Forks

Languages