fix: adds query constraint to ensureMaxVersions query

This commit is contained in:
Jarrod Flesch
2023-02-10 11:37:36 -05:00
parent d42b5d4989
commit 30688bbe41

View File

@@ -27,9 +27,16 @@ export const enforceMaxVersions = async ({
if (oldestAllowedDoc?.[0]?.updatedAt) {
await Model.deleteMany({
updatedAt: {
$lte: oldestAllowedDoc[0].updatedAt,
},
$and: [
{
parent: id,
},
{
updatedAt: {
$lte: oldestAllowedDoc[0].updatedAt,
},
},
],
});
}
} catch (err) {