📝 What's Changed
1.Added possibility to disable BigInt parsing during deserialisation. @dawidranda found that Regexp-based parsing causes high-CPU usage and pauses the event loop in concurrent scenarios. Replaced it with a simpler and naive way, and added a way to disable that by calling:
import { setNodePostgresTypeRawParser } from '@event-driven-io/dumbo`;
setNodePostgresTypeRawParser( { force: true });❗ IMPORTANT: In version 0.17.0 this will be a default behaviour and you'll need to opt in to enable non-default parsing.
- Added document schema versioning capabilities through upcast and downcast methods. You can use it both to version your document schema (if you have multiple app versions and you don't want to do a migration), or to map date or bigint fields explicitly.
Example:
type UserDocV1 = {
name: string;
createdAt: string;
lastLogin: string;
};
type UserDocV2 = {
profile: {
name: string;
};
timestamps: {
createdAt: Date;
lastLogin: Date;
};
};
type StoredPayload = UserDocV1 & UserDocV2;
const upcast = (doc: StoredPayload): UserDocV2 => ({
profile: doc.profile ?? { name: doc.name },
timestamps: {
createdAt: new Date(doc.timestamps?.createdAt ?? doc.createdAt),
lastLogin: new Date(doc.timestamps?.lastLogin ?? doc.lastLogin),
},
});
// this creates payload that's backward and forward compatible
const downcast = (doc: UserDocV2): StoredPayload => ({
name: doc.profile.name,
createdAt: doc.timestamps.createdAt.toISOString(),
lastLogin: doc.timestamps.lastLogin.toISOString(),
profile: doc.profile,
timestamps: doc.timestamps,
});
const collection = pongoDb.collection<UserDocV2, StoredPayload>(
'versioning_downcast_upcast',
{
schema: { versioning: { upcast, downcast } },
},
);By @oskardudycz in #145, #146, #147
Full Changelog: 0.16.5...0.16.8