@textile/hub > Client > create
Client.create() method
Creates a new model instance in the given store.
Signature:
create(threadID: ThreadID, collectionName: string, values: any[]): Promise<string[]>;
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<string[]>
Example
Create a new entry in our collection
import {Client, ThreadID, Where} from '@textile/hub'
interface Astronaut {
name: string
missions: number
_id: string
}
async function createBuzz (client: Client, threadID: ThreadID) {
const buzz: Astronaut = {
name: 'Buzz',
missions: 2,
_id: '',
}
await client.create(threadID, 'astronauts', [buzz])
}