@textile/hub > Client > delete
Client.delete() method
Deletes an existing model instance from the given store.
Signature:
delete(threadID: ThreadID, collectionName: string, IDs: string[]): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
threadID | ThreadID | the ID of the database |
collectionName | string | The human-readable name of the model to use. |
IDs | string[] | An array of instance ids to delete. |
Returns:
Promise<void>
Example
Delete any instances that return from a query
import {Client, ThreadID, Where} from '@textile/hub'
interface Astronaut {
name: string
missions: number
_id: string
}
async function deleteBuzz (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 ids = await result.map((instance) => instance._id)
await client.delete(threadID, 'astronauts', ids)
}