Skip to content

Commit

Permalink
adjust update call
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Dec 19, 2023
1 parent 103ff7a commit 120eea5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/capabilities.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { currentSchemaVersions } from '@mapeo/schema'
import mapObject from 'map-obj'
import { kCreateWithDocId } from './datatype/index.js'
import { valueOf } from './utils.js'

// Randomly generated 8-byte encoded as hex
export const COORDINATOR_ROLE_ID = 'f7c150f5a3a9a855'
Expand Down Expand Up @@ -287,10 +286,14 @@ export class Capabilities {
.catch(() => null)

if (existingRoleDoc) {
await this.#dataType.update(existingRoleDoc.versionId, {
...valueOf(existingRoleDoc),
roleId,
})
await this.#dataType.update(
[existingRoleDoc.versionId, ...existingRoleDoc.forks],
{
schemaName: 'role',
roleId,
fromIndex,
}
)
} else {
await this.#dataType[kCreateWithDocId](deviceId, {
schemaName: 'role',
Expand Down

0 comments on commit 120eea5

Please sign in to comment.