* Advances the clusterTime for a ClientSession to the provided clusterTime of another ClientSession * * @param clusterTime - the $clusterTime returned by the server from another session in the form of a document containing the `BSON.Timestamp` clusterTime and signature
(clusterTime: ClusterTime)
| 318 | * @param clusterTime - the $clusterTime returned by the server from another session in the form of a document containing the `BSON.Timestamp` clusterTime and signature |
| 319 | */ |
| 320 | advanceClusterTime(clusterTime: ClusterTime): void { |
| 321 | if (!clusterTime || typeof clusterTime !== 'object') { |
| 322 | throw new MongoInvalidArgumentError('input cluster time must be an object'); |
| 323 | } |
| 324 | if (!clusterTime.clusterTime || clusterTime.clusterTime._bsontype !== 'Timestamp') { |
| 325 | throw new MongoInvalidArgumentError( |
| 326 | 'input cluster time "clusterTime" property must be a valid BSON Timestamp' |
| 327 | ); |
| 328 | } |
| 329 | if ( |
| 330 | !clusterTime.signature || |
| 331 | clusterTime.signature.hash?._bsontype !== 'Binary' || |
| 332 | (typeof clusterTime.signature.keyId !== 'bigint' && |
| 333 | typeof clusterTime.signature.keyId !== 'number' && |
| 334 | clusterTime.signature.keyId?._bsontype !== 'Long') // apparently we decode the key to number? |
| 335 | ) { |
| 336 | throw new MongoInvalidArgumentError( |
| 337 | 'input cluster time must have a valid "signature" property with BSON Binary hash and BSON Long keyId' |
| 338 | ); |
| 339 | } |
| 340 | |
| 341 | _advanceClusterTime(this, clusterTime); |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Used to determine if this session equals another |