@textile/hub > Client > joinFromInfo
Client.joinFromInfo() method
Connect client to an existing database using information in the DBInfo object This should be called before any operation on the store, and is an alternative to open, which re-opens a database already opened by the user.
Signature:
joinFromInfo(info: DBInfo, includeLocal?: boolean, collections?: Array<CollectionConfig>): Promise<ThreadID>;
Parameters
Parameter | Type | Description |
---|---|---|
info | DBInfo | The output from a call to getDBInfo on a separate peer. |
includeLocal | boolean | Whether to try dialing addresses that appear to be on the local host. Defaults to false, preferring to add from public ip addresses. |
collections | Array<CollectionConfig> | Array of name and JSON schema pairs for seeding the DB with collections. |
Returns:
Promise<ThreadID>
Remarks
This is a helper method around newDBFromAddr, which takes the 'raw' output from getDBInfo. See getDBInfo for a possible source of the address and keys.
Example
Get DB info and use DB info to join an existing remote thread (e.g. invited)
import {Client, DBInfo, ThreadID} from '@textile/hub'
async function getInfo (client: Client, threadID: ThreadID): Promise<DBInfo> {
return await client.getDBInfo(threadID)
}
async function joinFromInfo (client: Client, info: DBInfo) {
return await client.joinFromInfo(info)
}