Skip to content

Commit e86b308

Browse files
committed
slgihtly updated readme
1 parent 0faa849 commit e86b308

File tree

1 file changed

+4
-66
lines changed

1 file changed

+4
-66
lines changed

README.md

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
`astra-db-ts` is a TypeScript client for interacting with [DataStax Astra DB](https://astra.datastax.com/signup).
44

5-
*This README targets v1.0.0+, which introduces a whole new API. Click [here](https://github.com/datastax/astra-db-ts/tree/90ebeac6fec53fd951126c2bcc010c87f7f678f8?tab=readme-ov-file#datastaxastra-db-ts) for the pre-existing client readme.*
5+
> **Warning**
6+
> This README is still under construction; parts of it may be incomplete or outdated.
7+
8+
*This README targets v2.0.0+, which introduces a whole new API. Click [here](https://github.com/datastax/astra-db-ts/tree/v1.x?tab=readme-ov-file#datastaxastra-db-ts) for the pre-existing client readme.*
69

710
## Table of contents
811
- [Quickstart](#quickstart)
@@ -243,18 +246,6 @@ interface Person {
243246
// @ts-expect-error - 'eyeColor' does not exist in type MaybeId<Person>
244247
eyeColor: 'blue',
245248
});
246-
247-
// You can use the 'Strict*' version of Sort/Projection/Filter/UpdateFilter for proper type-checking and autocomplete
248-
await collection.findOne({
249-
// @ts-expect-error - Type number is not assignable to type FilterExpr<UUID | undefined>
250-
'interests.friend': 3,
251-
} satisfies StrictFilter<Person>, {
252-
sort: {
253-
name: 1,
254-
// @ts-expect-error - 'interests.favoriteColor' does not exist in type StrictProjection<Person>
255-
'interests.favoriteColor': 1 as const,
256-
} satisfies StrictSort<Person>,
257-
});
258249
})();
259250
```
260251

@@ -347,59 +338,6 @@ const db = client.db('*ENDPOINT*', { namespace: '*NAMESPACE*' });
347338
})();
348339
```
349340

350-
## Monitoring/logging
351-
352-
[Like Mongo](https://www.mongodb.com/docs/drivers/node/current/fundamentals/logging/), `astra-db-ts` doesn't provide a
353-
traditional logging system—instead, it uses a "monitoring" system based on event emitters, which allow you to listen to
354-
events and log them as you see fit.
355-
356-
Supported events include `commandStarted`, `commandSucceeded`, `commandFailed`, and `adminCommandStarted`,
357-
`adminCommandPolling`, `adminCommandSucceeded`, `adminCommandFailed`.
358-
359-
Note that it's disabled by default, and it can be enabled by passing `monitorCommands: true` option to the root options'
360-
`dbOptions` and `adminOptions`.
361-
362-
```typescript
363-
import { DataAPIClient } from '@datastax/astra-db-ts';
364-
365-
const client = new DataAPIClient('*TOKEN*', {
366-
dbOptions: {
367-
monitorCommands: true,
368-
},
369-
});
370-
const db = client.db('*ENDPOINT*');
371-
372-
client.on('commandStarted', (event) => {
373-
console.log(`Running command ${event.commandName}`);
374-
});
375-
376-
client.on('commandSucceeded', (event) => {
377-
console.log(`Command ${event.commandName} succeeded in ${event.duration}ms`);
378-
});
379-
380-
client.on('commandFailed', (event) => {
381-
console.error(`Command ${event.commandName} failed w/ error ${event.error}`);
382-
});
383-
384-
(async () => {
385-
// Should log
386-
// - "Running command createCollection"
387-
// - "Command createCollection succeeded in <time>ms"
388-
const collection = await db.createCollection('my_collection', { checkExists: false });
389-
390-
// Should log
391-
// - "Running command insertOne"
392-
// - "Command insertOne succeeded in <time>ms"
393-
await collection.insertOne({ name: 'Queen' });
394-
395-
// Remove all monitoring listeners
396-
client.removeAllListeners();
397-
398-
// Cleanup (if desired) (with no logging)
399-
await collection.drop();
400-
})();
401-
```
402-
403341
## Non-astra support
404342

405343
`astra-db-ts` officially supports Data API instances using non-Astra backends, such as Data API on DSE or HCD.

0 commit comments

Comments
 (0)