This guide documents intentional behavioural and contract changes between monSQLize v1.x and v2.x. Most v2 type-level differences from v1 have been softened (optional fields, alias keys, permissive callbacks) so that v1 fixtures and call sites continue to type-check unchanged. The items below are the deliberately tightened semantics that v2 keeps for safety; v1 callers in these spots may need code changes.
- v1 returned
undefinedwhen no document matched. - v2 returns
null, matching the underlying MongoDB driver and removing theundefinedvsnullambiguity. - Migration: replace
result === undefinedwithresult === null, or use!resultwhich works for both.
- v1 returned an opaque object whose shape was not declared.
- v2 returns a
PoolHandleinterface with documented fields (name,client, etc.). - Migration: no source change is required if you only consume fields
v2 declares. If your v1 code accessed undeclared fields, declare them
through module augmentation or assert through
as unknown as ....
- The cache
publish()/ subscriber callback payload type is nowunknowninstead ofany, forcing call sites to narrow before use. - Migration: add a runtime check or a type assertion at the consumption point. The wire shape is unchanged.
For reference, v2 type files were extended with the following alias / optional fields so that v1 fixtures and runtime payloads continue to type-check; you do not need to migrate code for these:
BatchRetryRecord: added optionalattempts(alias ofattempt) andsuccess?: boolean. The runtime now also emits both fields on retry records to match v1.FindPageOptions: added top-levelcomment?: stringshortcut that mirrorsoptions.comment.SagaContext.get<T = any>: default generic relaxed fromunknowntoanyto match v1 ergonomics.SagaResult.sagaId/sagaName: marked optional alongsideexecutionId.SagaStats: aliased v2-only fields (successfulExecutions/failedExecutions/compensatedExecutions) are optional;successCount/failureCount/compensationCountremain the v1 primary fields.MongoSession.transaction?.state: re-exposed for v1 callers readingsession.transaction?.state.SyncConfig.transform: accepts both v1 single-arg(document) => ...and v2(document, event) => ...forms.Lock.released: markedreadonlyto match v1.PoolStats: counter fields are optional to accept v1 fixture shapes.
If a previously-undocumented field still does not type-check, please file an issue with the v1 reproduction so the public types can be extended.