Optional
adminThe default options when spawning an AstraAdmin instance.
Optional
callerThe caller information to send with requests, of the form [name, version?]
, or an array of such.
Intended generally for integrations or frameworks that wrap the client.
The caller information is used to identify the client making requests to the server.
It will be sent in the headers of the request as such:
User-Agent: ...<name>/<version> astra-db-ts/<version>
If no caller information is provided, the client will simply be identified as astra-db-ts/<version>
.
NB. If providing an array of callers, they should be ordered from most important to least important.
// 'my-app/1.0.0 astra-db-ts/1.0.0'
const client1 = new DataAPIClient('AstraCS:...', {
caller: ['my-app', '1.0.0'],
});
// 'my-app/1.0.0 my-other-app astra-db-ts/1.0.0'
const client2 = new DataAPIClient('AstraCS:...', {
caller: [['my-app', '1.0.0'], ['my-other-app']],
});
Optional
dbThe default options when spawning a Db instance.
Optional
environmentSets the Data API "backend" that is being used (e.g. 'dse', 'hcd', 'cassandra', or 'other'). Defaults to 'astra'.
Generally, the majority of operations stay the same between backends. However, authentication may differ, and availability of admin operations does as well.
With Astra databases, you'll use an 'AstraCS:...'
token; for other backends, you'll generally want to use the
UsernamePasswordTokenProvider, or, rarely, even create your own.
AstraAdmin is only available on Astra databases. AstraDbAdmin is also only available on Astra databases, but the DataAPIDbAdmin alternative is used for all other backends, albeit the expense of a couple extra features.
Some functions/properties may also not be available on non-Astra backends, such as Db.id or Db.info.
No error will be thrown if this is set incorrectly, but bugs may appear in your code, with some operations just throwing errors and refusing to work properly.
"astra"
Optional
httpThe client-wide options related to http operations.
There are four different behaviours for setting the client:
httpOptions
at all
-- This will attempt to use fetch-h2
if available, and fall back to fetch
if not availableclient: 'default'
or client: undefined
(or unset)
-- This will attempt to use fetch-h2
if available, and throw an error if not availableclient: 'fetch'
-- This will always use the native fetch
APIclient: 'custom'
-- This will allow you to pass a custom Fetcher
implementation to the clientfetch-h2
is a fetch implementation that supports HTTP/2, and is the recommended client for the best performance.
However, it's generally only available by default on node runtimes; in other environments, you may need to use the
native fetch
API instead, or pass in the fetch-h2 module manually.
See the astra-db-ts
README for more information on different clients.
Optional
loggingThe configuration for logging events emitted by the DataAPIClient.
This can be set at any level of the major class hierarchy, and will be inherited by all child classes.
See DataAPILoggingConfig for much more information on configuration, outputs, and inheritance.
TL;DR: Set logging: 'all'
for a sane default.
Optional
timeoutThe default timeout options for anything spawned by this DataAPIClient instance.
See TimeoutDescriptor for much more information about timeouts.
// The request timeout for all operations is set to 1000ms.
const client = new DataAPIClient('...', {
timeoutDefaults: { requestTimeoutMs: 1000 },
});
// The request timeout for all operations borne from this Db is set to 2000ms.
const db = client.db('...', {
timeoutDefaults: { requestTimeoutMs: 2000 },
});
The timeout options are inherited by all child classes, and can be overridden at any level, including the individual method level.
Individual-method-level overrides can vary in behavior depending on the method; again, see TimeoutDescriptor.
The default timeout options are as follows:
requestTimeoutMs
: 10000generalMethodTimeoutMs
: 30000collectionAdminTimeoutMs
: 60000tableAdminTimeoutMs
: 30000databaseAdminTimeoutMs
: 600000keyspaceAdminTimeoutMs
: 30000TimeoutDescriptor
The default options for the DataAPIClient. The Data API & DevOps specific options may be overridden when spawning a new instance of their respective classes.