Skip to content

Commit 685a6d0

Browse files
committed
docs: update oid deprecation migration
1 parent 98eff70 commit 685a6d0

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
@@ -89,12 +89,17 @@ This library no longer polyfills [ES Map](https://developer.mozilla.org/en-US/do
8989
The following deprecated methods have been removed:
9090

9191
- `ObjectId.prototype.generate`
92-
- Instead, generate a new ObjectId with the constructor: `new ObjectId()`
92+
- Instead, generate a new ObjectId with the constructor: `new ObjectId()` or using the `static generate(time?: number)` method.
93+
- `ObjectId.prototype.generationTime`
94+
- Instead, use `static createFromTime()` and `getTimestamp()` to set and inspect these values on an `ObjectId()`
9395

9496
- `ObjectId.prototype.getInc`
9597
- `ObjectId.prototype.get_inc`
9698
- `ObjectId.get_inc`
97-
- 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.
99+
- 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.
100+
- See the following code snippet for how to obtain the counter field of an ObjectId:
98101

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

0 commit comments

Comments
 (0)