You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you prefer to use `DataAPITimestamp`s for interop with tables, that's also allowed, though you'll need to enable a certain codec if you want to read the date back as a `DataAPITimestamp`.
144
-
145
-
-`DataAPITimestamp`s will still serialize to a `$date` by default, even if you don't set the necessary codec.
You can use objectIds in collections using the `ObjectId` class (or the `oid` shorthand). Make sure you're importing this from `'@datastax/astra-db-ts'`, and _not_ from `'bson'`.
You can create these classes through the constructor function, or through the respective shorthand, by providing the date/time/duration in a few different ways:
341
+
You can create the custom classes through the constructor function, or through their respective shorthands, by providing the date/time/duration in a few different ways:
359
342
1. As a raw string formatted as it would be stored in the database (`'1992-05-28'`, `'12:34:56'`, `'2021-09-30T12:34:56.789Z'`, `'P5DT30M'`)
360
343
2. As a `Date` object (`new Date(1734070574056)`)
361
-
- Durations are the exception here, as they doesn't have a direct `Date` equivalent
344
+
- Durations are the exception here, as they don't have a direct `Date` equivalent
362
345
3. As the `*Components` object for that respective class (e.g. `{ year: 1992, month: 5, day: 28 }`)
363
346
364
-
From each class, you can generally:
347
+
From each custom class, you can generally:
365
348
- Get the string representation of the date/time/duration using `.toString()`
366
349
- Get the date/time as a `Date` object using `.toDate()`
367
350
- Get the individual components of the date/time using `.components()`
@@ -498,29 +481,29 @@ If you really want to change the behavior of how a certain type is deserialized,
0 commit comments