Impl delete find filters for boltdb

This commit is contained in:
Bel LaPointe
2020-07-23 16:41:50 -06:00
parent 085150a7b5
commit bed265a228
13 changed files with 670 additions and 92 deletions

View File

@@ -3,6 +3,7 @@ package storage
import (
"context"
"fmt"
"local/dndex/storage/driver"
"local/dndex/storage/entity"
"local/dndex/storage/operator"
@@ -10,13 +11,13 @@ import (
)
type Graph struct {
mongo Mongo
driver driver.Driver
}
func NewGraph() Graph {
mongo := NewMongo()
mongo := driver.NewMongo()
return Graph{
mongo: mongo,
driver: mongo,
}
}
@@ -31,7 +32,7 @@ func (g Graph) List(ctx context.Context, namespace string, from ...string) ([]en
}
func (g Graph) find(ctx context.Context, namespace string, filter interface{}) ([]entity.One, error) {
ch, err := g.mongo.Find(ctx, namespace, filter)
ch, err := g.driver.Find(ctx, namespace, filter)
if err != nil {
return nil, err
}
@@ -51,13 +52,13 @@ func (g Graph) gatherOnes(ctx context.Context, ch <-chan bson.Raw) ([]entity.One
}
func (g Graph) Insert(ctx context.Context, namespace string, one entity.One) error {
return g.mongo.Insert(ctx, namespace, one)
return g.driver.Insert(ctx, namespace, one)
}
func (g Graph) Update(ctx context.Context, namespace string, one entity.One, modify interface{}) error {
return g.mongo.Update(ctx, namespace, one, modify)
return g.driver.Update(ctx, namespace, one, modify)
}
func (g Graph) Delete(ctx context.Context, namespace string, filter interface{}) error {
return g.mongo.Delete(ctx, namespace, filter)
return g.driver.Delete(ctx, namespace, filter)
}