Commit 157fafb1 authored by Akshay Bharambe's avatar Akshay Bharambe
Browse files

Remove: Commented code from dgraph

parent 8d30bcec
2 merge requests!188V2 : mep deployemet28 april2020,!183Add: Transactions support for graph db operations.
Showing with 0 additions and 51 deletions
......@@ -185,10 +185,6 @@ func GetTransaction(hostName string) (*dgo.Txn, error) {
//
// The result is against the provided key in the query.
func (dg *DGraphDAO) GetData(ctx context.Context, query string, vars map[string]string) ([]byte, error) {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return nil, err
// }
txn := dg.instance.client.NewReadOnlyTxn().BestEffort()
var (
......@@ -256,10 +252,6 @@ func (dg *DGraphDAO) DeleteDataTXN(ctx context.Context, txn *dgo.Txn, data []byt
//
// Ex. Persion1 `follows` Person2.
func (dg *DGraphDAO) DeleteEdge(ctx context.Context, uid string, predicates ...string) error {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return err
// }
mu := &api.Mutation{
CommitNow: true,
......@@ -276,10 +268,6 @@ func (dg *DGraphDAO) DeleteEdge(ctx context.Context, uid string, predicates ...s
//
// Ex. Persion1 `follows` Person2.
func (dg *DGraphDAO) DeleteEdgeTXN(ctx context.Context, txn *dgo.Txn, uid string, predicates ...string) error {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return err
// }
mu := &api.Mutation{
CommitNow: true,
......@@ -287,17 +275,11 @@ func (dg *DGraphDAO) DeleteEdgeTXN(ctx context.Context, txn *dgo.Txn, uid string
dgo.DeleteEdges(mu, uid, predicates...)
// // mu.CommitNow = true
// _, err := dg.instance.client.NewTxn().Mutate(ctx, mu)
return dg.mutateTXN(ctx, mu, txn)
}
// mutate creates or updates or deletes the node data.
func (dg *DGraphDAO) mutate(ctx context.Context, mtn *api.Mutation) error {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return err
// }
txn := dg.instance.client.NewTxn()
......@@ -314,59 +296,26 @@ func (dg *DGraphDAO) mutateTXN(ctx context.Context, mtn *api.Mutation, txn *dgo.
return err
}
// // DropEdge deletes the edges for the mentioned node. predicate is the name of relationship between the node.
// //
// // Ex. Persion1 `follows` Person2.
// func (dg *DGraphDAO) DropEdge(ctx context.Context, uid string, predicates ...string) error {
// // instance, err := GetInstance(dg.HostName)
// // if err != nil {
// // return err
// // }
// mu := &api.Mutation{}
// dgo.DeleteEdges(mu, uid, predicates...)
// mu.CommitNow = true
// _, err := dg.instance.client.NewTxn().Mutate(ctx, mu)
// return err
// }
// CreateSchema sets the provided schema for the nodes data.
func (dg *DGraphDAO) CreateSchema(ctx context.Context, schema string) error {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return err
// }
return dg.instance.client.Alter(ctx, &api.Operation{Schema: schema})
}
// DropSchema deletes the current schema along with the data.
func (dg *DGraphDAO) DropSchema(ctx context.Context) error {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return err
// }
return dg.instance.client.Alter(ctx, &api.Operation{DropOp: api.Operation_ALL})
}
// DropData deletes complete data but maintains the schema.
func (dg *DGraphDAO) DropData(ctx context.Context) error {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return err
// }
return dg.instance.client.Alter(ctx, &api.Operation{DropOp: api.Operation_DATA})
}
// DropAttr deletes a specific attribute completely from data and the schema.
func (dg *DGraphDAO) DropAttr(ctx context.Context, attr string) error {
// instance, err := GetInstance(dg.HostName)
// if err != nil {
// return err
// }
return dg.instance.client.Alter(ctx, &api.Operation{DropOp: api.Operation_ATTR, DropValue: attr})
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment