ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
664 stars 55 forks source link

using badger as shown in readme does not work #154

Open l0ngest opened 1 week ago

l0ngest commented 1 week ago

Hi there, thanks in advance for your time. Looking at this part of the readme:

import (
  "log"
  "github.com/dgraph-io/badger/v4"
  c "github.com/ostafen/clover"
  badgerstore "github.com/ostafen/clover/v2/store/badger"
)

...

// by default, Bolt will be used internally
db, _ := c.Open("clover-db")

// use OpenWithStore() if you want to select a different storage backend
store, _ := badgerstore.Open(badger.DefaultOptions("").WithInMemory(true)) // opens a badger in memory database
db, _ := c.OpenWithStore(store)

defer db.Close() // remember to close the db when you have done

I have copy-pasted this exactly, but on this line: store, _ := badgerstore.Open(badger.DefaultOptions("").WithInMemory(true)) // opens a badger in memory database

I get this error: "Cannot use 'badger.DefaultOptions("").WithInMemory(true)' (type "github.com/dgraph-io/badger/v4".Options) as the type "github.com/dgraph-io/badger/v3".Options"

It appears that if I use badger v3 it works; however, given that the readme example uses badger v4 I spent a while thinking I've done something wrong. Is badger v4 not supported?

ostafen commented 1 week ago

Are you sure you are pulling the latest version? Clover is using badger v4