Skip to content

Commit 749be6d

Browse files
committed
docs: update oid deprecation migration
1 parent d919e62 commit 749be6d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

docs/upgrade-to-v5.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,17 @@ This library no longer polyfills [ES Map](https://developer.mozilla.org/en-US/do
9393
The following deprecated methods have been removed:
9494

9595
- `ObjectId.prototype.generate`
96-
- Instead, generate a new ObjectId with the constructor: `new ObjectId()`
96+
- Instead, generate a new ObjectId with the constructor: `new ObjectId()` or using the `static generate(time?: number)` method.
97+
- `ObjectId.prototype.generationTime`
98+
- Instead, use `static createFromTime()` and `getTimestamp()` to set and inspect these values on an `ObjectId()`
9799

98100
- `ObjectId.prototype.getInc`
99101
- `ObjectId.prototype.get_inc`
100102
- `ObjectId.get_inc`
101-
- The `static getInc()` is private now since it has a side effect of changing the value of the next `ObjectId` generated, using `new ObjectId()` and inspecting the increment section of the bytes can provide insight into the current increment value.
103+
- The `static getInc()` is private since invoking it increments the next `ObjectId` index, instead users should inspect the counter on newly created ObjectId if it is needed.
104+
- See the following code snippet for how to obtain the counter field of an ObjectId:
102105

103-
- `ObjectId.prototype.generationTime`
104-
- Instead, use `static createFromTime()` and `getTimestamp()` to set and inspect these values on an `ObjectId()`
106+
```ts
107+
const oid = new ObjectId();
108+
const counterField = oid.id[9] << 16 | oid.id[10] << 8 | oid.id[11];
109+
```

0 commit comments

Comments
 (0)