Skip to content

Commit

Permalink
JSCBC-1126: Add mutation token to MutateInResult
Browse files Browse the repository at this point in the history
Motivation
----------
MutateIn operations should provide a result object that contains a
mutation token.

Changes
-------
Added the mutation token to the MutateInResult object.  Added tests to
verify mutation token is in MutateInResult.

Change-Id: Idfbe0beb43a0e54712f6158daf5b503ce74fbc35
Reviewed-on: https://review.couchbase.org/c/couchnode/+/186442
Tested-by: Jared Casey <jared.casey@couchbase.com>
Reviewed-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
thejcfactor committed Feb 8, 2023
1 parent 605b0a4 commit 463d648
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,7 @@ export class Collection {
new MutateInResult({
content: content,
cas: resp.cas,
token: resp.token,
})
)
return
Expand Down
6 changes: 6 additions & 0 deletions lib/crudoptypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,18 @@ export class MutateInResult {
*/
cas: Cas

/**
* The token representing the mutation performed.
*/
token?: MutationToken

/**
* @internal
*/
constructor(data: MutateInResult) {
this.content = data.content
this.cas = data.cas
this.token = data.token
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/crud.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,7 @@ function genericTests(collFn) {
])
assert.isObject(res)
assert.isOk(res.cas)
validateMutationToken(res.token)

assert.isUndefined(res.content[0].error)
assert.strictEqual(res.content[0].value, 5)
Expand Down Expand Up @@ -1311,6 +1312,7 @@ function genericTests(collFn) {
)
assert.isObject(res)
assert.isOk(res.cas)
validateMutationToken(res.token)

assert.isUndefined(res.content[0].error)
assert.strictEqual(res.content[0].value, 5)
Expand Down Expand Up @@ -1358,6 +1360,7 @@ function genericTests(collFn) {
)
assert.isObject(res)
assert.isOk(res.cas)
validateMutationToken(res.token)

assert.isUndefined(res.content[0].error)
assert.strictEqual(res.content[0].value, 5)
Expand Down

0 comments on commit 463d648

Please sign in to comment.