Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DgraphMapper封装Upsert方法 #21

Open
wangyuheng opened this issue Oct 16, 2020 · 0 comments
Open

DgraphMapper封装Upsert方法 #21

wangyuheng opened this issue Oct 16, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@wangyuheng
Copy link
Owner

wangyuheng commented Oct 16, 2020

背景

DgraphMapper提供了querymutation方法,但是涉及到var的使用,需要同时提供querymutation。比如: 某个记录的字段+1, 需要执行

upsert {
  query {
            q(func: uid($id)) {
                v as uid
                usageCount as PROJECT.usageCount
                u as math(usageCount+1)
            }
  }
  mutation {
    set {
      uid(v) <PROJECT.usageCount> val(u) .
    }
  }
}

方案

通过扩展xml中标签实现

<upsert id="testUpsert">
    <query id="testQuery">
        query {
            q(func: uid($id)) {
                v as uid
                usageCount as PROJECT.usageCount
                u as math(usageCount+1)
            }
        }
    </query>
    <mutation id="updateStatus">
        <![CDATA[
            uid(v) <PROJECT.usageCount> val(u) .
        ]]>
    </mutation>
</upsert>

验收

通过xml完成upsert

@wangyuheng wangyuheng added the enhancement New feature or request label Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant