Hey @amanmangal, I saw Add support for multiple mutations in an upsert query · Issue #3817 · dgraph-io/dgraph · GitHub
what about the “bulk/massive upsert” thing I’ve mentioned 2 months ago? Do you think it should be a new issue or related to 3817?
“How to Update millions or records in a table” a common SQL question.
The ref query.
upsert {
query {
me(func: regexp(email, /^*@dgraph.io*$/)) {
v as uid
}
}
mutation {
set {
uid(v) <WorksAt> "Dgraph Labs" .
#fix typo "Dgraph Lab" to "Dgraph Labs"
}
}
}
If Dgraph finds 40 workers at “@dgraph.io”, we create 40 Nquads Clones with different uids or 40 mutation blocks. To add or update a new information.
This would be useful for games scenarios (distributing score to groups of a game), social networks, contextualized changes(like, someone typo the company’s name and we need to alter it in several context levels - could means thousands of nodes) and so on.
upsert {
query {
me(func: eq(team, "Manchester United RPG Club")) {
rpgTeam {
v as uid
}
}
}
mutation {
set {
uid(v) <overallTeamScore> "3000" .
}
}
}
Also this could be a kind of “drop/clean”. We need to delete a company from our DB. Let’s say that yellow company here has 2k employees. After delete all yellow’s information I wanna delete all employees from my DB due legal reasons.
upsert {
query {
me(func: regexp(email, /^*@yellow.company*$/)) {
v as uid
}
}
mutation {
delete {
uid(v) * * .
}
}
}
Also delete a thread posts from a social network
upsert {
query {
me(func: regexp(username, "@MichelDiz")) {
posts @filter(eq(postID, "156358129154782120") {
POST as uid
rootcmts as comments {
TH as thread {
cmts as comments {
WHO as ~commented
}
}
}
}
}
}
mutation {
delete {
uid(POST) * * .
uid(rootcmts) * * .
uid(TH) * * .
uid(cmts) * * .
uid(WHO) <commented> uid(cmts) . #This deletes a reverse edge
#from users that commented there.
}
}
}