@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
Parameter | Type | Description |
---|---|---|
threadID | ThreadID | the ID of the database |
collectionName | string | The human-readable name of the model to use. |
values | any[] | 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])
}