Skip to content

Commit 3a4638a

Browse files
committed
Add property-based testing + more tests & bug fixes (#108)
<lot of test-work-related commits omitted> * replace nyc with c8 (nyc has issues with esm) * remove DevOpsUnexpectedStateError * some events tests + minor internal events refatoring to make things work * throw serialization errors for datatypes used in wrong schema object * update rerank cursor tests with new options * start integration testing cursor deduping & farr cursor testing * disabe $binary ser for vectors in sorts * add better formatting for +<Promise> repl macro * added coll_ and table_ to repl script as default variables * add reranking test tag (either astra-dev or non-astra) * uuid\((\d)\) -> uuid.v$1() * fixed mistake with altertableoptions type * add sort vector to FARR cursor * add string.includes-before-string.split optimization (thanks val) * allow objectid to be constructed from another objectid
1 parent 7ffa27e commit 3a4638a

File tree

168 files changed

+8361
-4157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+8361
-4157
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,4 @@ tmp-lib-check
144144
!examples/astra-db-ts.tgz
145145

146146
.direnv
147+
.mocha

etc/astra-db-ts.api.md

Lines changed: 113 additions & 84 deletions
Large diffs are not rendered by default.

etc/docs/DATATYPES.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import { oid, uuid, vector } from '@datastax/astra-db-ts';
6363

6464
await collection.insertOne({
6565
date: new Date(),
66-
uuid: uuid(4),
66+
uuid: uuid.v4(),
6767
oid: oid(),
6868
$vector: vector([.1, .2, .3]),
6969
});
@@ -172,7 +172,7 @@ You can use UUIDs in collections using the `UUID` class (or the `uuid` shorthand
172172
import { UUID, uuid } from '@datastax/astra-db-ts';
173173

174174
await collection.insertOne({
175-
_id: uuid(4), // Equivalent to `UUID.v4()`
175+
_id: uuid.v4(), // Equivalent to `UUID.v4()`
176176
});
177177

178178
const doc = await collection.findOne();
@@ -182,7 +182,7 @@ console.log(doc._id instanceof UUID); // true
182182
You can create a `UUID` through the class, or through the `uuid` shorthand, in a few different ways:
183183
1. By passing the UUID string to `new UUID()` or `uuid()`
184184
2. By using `UUID.v1()`, `.v4()`, `.v6()`, or `.v7()` to generate a new UUID of the respective version
185-
3. By using `uuid(1)`, `uuid(4)`, `uuid(6)`, or `uuid(7)` to generate a new UUID of the respective version
185+
3. By using `uuid.v1()`, `uuid.v4()`, `uuid.v6()`, or `uuid.v7()` to generate a new UUID of the respective version
186186

187187
From the `UUID` class, you can either:
188188
- Get the string representation of the `UUID` using `.toString()`
@@ -356,7 +356,7 @@ You can use UUIDs in collections using the `UUID` class (or the `uuid` shorthand
356356
import { UUID, uuid } from '@datastax/astra-db-ts';
357357

358358
await table.insertOne({
359-
uuid: uuid(4), // Equivalent to `UUID.v4()`
359+
uuid: uuid.v4(), // Equivalent to `UUID.v4()`
360360
});
361361

362362
const row = await table.findOne();
@@ -366,7 +366,7 @@ console.log(row.uuid instanceof UUID); // true
366366
You can create a `UUID` through the class, or through the `uuid` shorthand, in a few different ways:
367367
1. By passing the UUID string to `new UUID()` or `uuid()`
368368
2. By using `UUID.v1()`, `.v4()`, `.v6()`, or `.v7()` to generate a new UUID of the respective version
369-
3. By using `uuid(1)`, `uuid(4)`, `uuid(6)`, or `uuid(7)` to generate a new UUID of the respective version
369+
3. By using `uuid.v1()`, `uuid.v4()`, `uuid.v6()`, or `uuid.v7()` to generate a new UUID of the respective version
370370

371371
From the `UUID` class, you can either:
372372
- Get the string representation of the `UUID` using `.toString()`
@@ -450,7 +450,7 @@ If you really want to change the behavior of how a certain type is deserialized,
450450
| Type | Type | Shorthand | Examples |
451451
|-------------|-----------------|-----------|----------------------------------------------------------------|
452452
| `$date` | `Date` | - | `new Date()` |
453-
| `$uuid` | `UUID` | `uuid` | `new UUID('...')`, `UUID.v4()`, `uuid('...')`, `uuid(7)` |
453+
| `$uuid` | `UUID` | `uuid` | `new UUID('...')`, `UUID.v4()`, `uuid('...')`, `uuid.v7()` |
454454
| `$objectId` | `ObjectId` | `oid` | `new ObjectId()`, `new ObjectId('...')`, `oid()`, `oid('...')` |
455455
| `$vector` | `DataAPIVector` | `vector` | `new DataAPIVector([.1, .2, .3])`, `vector([.1, .2, .3])` |
456456

@@ -477,9 +477,9 @@ If you really want to change the behavior of how a certain type is deserialized,
477477
| `text` | `string` | - | `'Hello!'` |
478478
| `time` | `DataAPITime` | `time` | `new DataAPITime()`, `time(new Date(1734070574056))`, `time('12:34:56')`, `time()` |
479479
| `timestamp` | `Date` | - | `new Date()`, `new Date(1734070574056)`, `new Date('...')` |
480-
| `timeuuid` | `UUID` | `uuid` | `new UUID('...')`, `UUID.v1()`, `uuid('...')`, `uuid(1)` |
480+
| `timeuuid` | `UUID` | `uuid` | `new UUID('...')`, `UUID.v1()`, `uuid('...')`, `uuid.v1()` |
481481
| `tinyint` | `number` | - | `42` |
482-
| `uuid` | `UUID` | `uuid` | `new UUID('...')`, `UUID.v4()`, `uuid('...')`, `uuid(7)` |
482+
| `uuid` | `UUID` | `uuid` | `new UUID('...')`, `UUID.v4()`, `uuid('...')`, `uuid.v7()` |
483483
| `varchar` | `string` | - | `'Hello!'` |
484484
| `varint` | `bigint` | - | `BigInt('42')`, `42n` |
485485
| `vector` | `DataAPIVector` | `vector` | `new DataAPIVector([.1, .2, .3])`, `vector([.1, .2, .3])` |

examples/astra-db-ts.tgz

5.19 KB
Binary file not shown.

examples/browser/package-lock.json

Lines changed: 54 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/cloudflare-workers/package-lock.json

Lines changed: 54 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)