Beta
Optional
Beta
collectionAdvanced & currently somewhat unstable features related to customizing spawned collections' ser/des behavior at a lower level.
Use with caution. See official DataStax documentation for more info.
Optional
mutateEnables an optimization which allows inserted rows/documents to be mutated in-place when serializing.
For example, when you insert a record like so:
import { uuid } from '@datastax/astra-db-ts';
await collection.insertOne({ name: 'Alice', friends: { john: uuid('...') } });
The document is internally serialized as such:
{ name: 'Alice', friends: { john: { $uuid: '...' } } }
To avoid mutating a user-provided object, the client will be forced to clone any objects that contain a custom datatype, as well as their parents (which looks something like this):
{ ...original, friends: { ...original.friends, john: { $uuid: '...' } } }
This can be a minor performance hit, especially for large objects, so if you're confident that you won't be needing the object after it's inserted, you can enable this option to avoid the cloning, and instead mutate the object in-place.
// Before
const collection = db.collection<User>('users');
const doc = { name: 'Alice', friends: { john: uuid(4) } };
await collection.insertOne(doc);
console.log(doc); // { name: 'Alice', friends: { john: UUID<4>('...') } }
// After
const collection = db.collection<User>('users', {
serdes: { mutateInPlace: true },
});
const doc = { name: 'Alice', friends: { john: UUID.v4() } };
await collection.insertOne(doc);
console.log(doc); // { name: 'Alice', friends: { john: { $uuid: '...' } } }
false
Optional
Beta
tableAdvanced & currently somewhat unstable features related to customizing spawned tables' ser/des behavior at a lower level.
Use with caution. See official DataStax documentation for more info.
Overview
The config for common table/collection serialization/deserialization logic.
Such custom logic may be used for various purposes, such as:
Disclaimer
This is an advanced feature, and should be used with caution. It's possible to break the client's behavior by using this feature incorrectly.
These features are currently generally unstable, and should generally not be used in production (except for a couple, such as
mutateInPlace
orenableBigNumbers
).See the official DataStax documentation for more info.
See