Dgraph: Add support for multiple mutations in an upsert query

Created on 15 Aug 2019  路  2Comments  路  Source: dgraph-io/dgraph

Related to #3059

arequerylang areupsert kinfeature prioritP1 statuaccepted

Most helpful comment

Just registering my interest in this issue/feature as I'd like to be able to do something like the example below.

Example

upsert {
  query {
    author(func: eq(emailAddress, "[email protected]") ) {
      authorEmail as uid
    }
  }

  mutation @if(eq(len(authorEmail), 0)) {
   set{
     _:me <name> "Robert Evans" .
     _:me <dgraph.type> "Author" . 
     _:me <emailAddress> "[email protected]" .

     _:commit <commitSha> "42b1817b6a48941304283e6fcb4fab13e6c80980" . 
     _:commit <collectionId> "96cc6a70-c1d3-11e9-80fd-1d01e09f90e7" .
     _:commit <commitSummary> "Fix/docs (#10)" .
     _:me <committed> _:commit .
     _:commit <committedBy> _:me .

   }
  }

  mutation @if(eq(len(authorEmail), 1)) { 
    set {
     _:commit <commitSha> "42b1817b6a48941304283e6fcb4fab13e6c80980" . 
     _:commit <collectionId> "96cc6a70-c1d3-11e9-80fd-1d01e09f90e7" .
     _:commit <commitSummary> "Fix/docs (#10)" .
     _:commit <committedBy> uid(authorEmail) .
     uid(authorEmail) <committed> _:commit .
    }
  } 
}

All 2 comments

Just registering my interest in this issue/feature as I'd like to be able to do something like the example below.

Example

upsert {
  query {
    author(func: eq(emailAddress, "[email protected]") ) {
      authorEmail as uid
    }
  }

  mutation @if(eq(len(authorEmail), 0)) {
   set{
     _:me <name> "Robert Evans" .
     _:me <dgraph.type> "Author" . 
     _:me <emailAddress> "[email protected]" .

     _:commit <commitSha> "42b1817b6a48941304283e6fcb4fab13e6c80980" . 
     _:commit <collectionId> "96cc6a70-c1d3-11e9-80fd-1d01e09f90e7" .
     _:commit <commitSummary> "Fix/docs (#10)" .
     _:me <committed> _:commit .
     _:commit <committedBy> _:me .

   }
  }

  mutation @if(eq(len(authorEmail), 1)) { 
    set {
     _:commit <commitSha> "42b1817b6a48941304283e6fcb4fab13e6c80980" . 
     _:commit <collectionId> "96cc6a70-c1d3-11e9-80fd-1d01e09f90e7" .
     _:commit <commitSummary> "Fix/docs (#10)" .
     _:commit <committedBy> uid(authorEmail) .
     uid(authorEmail) <committed> _:commit .
    }
  } 
}

@mangalaman93 I think this is already merged right? So we can close it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

armaneous picture armaneous  路  3Comments

mbudge picture mbudge  路  3Comments

xhochipe picture xhochipe  路  3Comments

KadoBOT picture KadoBOT  路  5Comments

pepoospina picture pepoospina  路  3Comments