timshannon / badgerhold

BadgerHold is an embeddable NoSQL store for querying Go types built on Badger
MIT License
517 stars 51 forks source link

Unique constraints #5

Closed brianhiss closed 5 years ago

brianhiss commented 5 years ago

@timshannon,

I enjoyed reading your article comparing boltdb-vs-badger. I've been flopping back and forth between the two of them, balancing the pros and cons of each.

That being said, I've been playing around with badgerhold. I wanted to know if you support anything like Storm, unique constraints on a field within a struct?

type User struct {
  ThePrimaryKey string `storm:"id"`// primary key
  Group string `storm:"index"` // this field will be indexed
  Email string `storm:"unique"` // this field will be indexed with a unique constraint
  Name string // this field will not be indexed
}

If not, is this something you'd consider? Doesn't seem like bolthold supports that use case either, but I've only skimmed through it and haven't used it extensively.

Thanks again for all your contributions, code and research.

timshannon commented 5 years ago

Not currently supported, but it's a great idea. I'll start working on it when I get a chance.

On Fri, Feb 15, 2019, 5:49 PM Brian M Hiss <notifications@github.com wrote:

@timshannon https://github.com/timshannon,

I enjoyed reading your article comparing boltdb-vs-badger. I've been flopping back and forth between the two of them, balancing the pros and cons of each.

That being said, I've been playing around with badgerhold. I wanted to know if you support anything like Storm, unique constraints on a field within a struct?

type User struct { ThePrimaryKey string storm:"id"// primary key Group string storm:"index" // this field will be indexed Email string storm:"unique" // this field will be indexed with a unique constraint Name string // this field will not be indexed }

If not, is this something you'd consider? Doesn't seem like bolthold supports that use case either, but I've only skimmed through it and haven't used it extensively.

Thanks again for all your contributions, code and research.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/timshannon/badgerhold/issues/5, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRNNaTiTq_zmFiLedlqesAAx0RCquoOks5vN0dzgaJpZM4a-ob9 .

timshannon commented 5 years ago

PR #7 Adds unique constraint support. All of my tests are passing, but if you run into any issues with it, because to open up an issue.

Thanks,

brianhiss commented 5 years ago

@timshannon, that was fast!

How do you use this, don't see anything in the docs yet? Something like:

`badgerhold:"unique"`
timshannon commented 5 years ago

Well shoot, I knew I forgot something.

Yeah that's exactly what you do. I'll update the README.

Thanks,

timshannon commented 5 years ago

README updated, thanks for the heads up.

brianhiss commented 5 years ago

Looks good, thanks! Will make it a lot more powerful for some interesting use cases.