Hub JS Package

Hub JS Package

  • Users
  • Buckets
  • Threads
  • Textile Docs

@textile/hub > Client > verify

Client.verify() method

Verify checks existing instance changes. Each model instance must have a valid existing _id property.

Signature:

verify(threadID: ThreadID, collectionName: string, values: any[]): Promise<void>;

Parameters

ParameterTypeDescription
threadIDThreadIDthe ID of the database
collectionNamestringThe human-readable name of the model to use.
valuesany[]An array of model instances as JSON/JS objects.

Returns:

Promise<void>

Example

Update an existing instance

import {Client, ThreadID, Where} from '@textile/hub'

interface Astronaut {
  name: string
  missions: number
  _id: string
}

async function verifyBuzz (client: Client, threadID: ThreadID) {
  const query = new Where('name').eq('Buzz')
  const result = await client.find<Astronaut>(threadID, 'astronauts', query)

  if (result.length < 1) return

  const buzz = result[0]
  buzz.missions += 1

  // Is this going to be a valid update?
  return await client.verify(threadID, 'astronauts', [buzz])
}

  • Client.verify() method
  • Parameters
  • Example
Hub JS Package
Docs
Getting StartedThreadDBBuckets
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @textileio