mswjs / data

Data modeling and relation library for testing JavaScript applications.

Home Page:https://npm.im/@mswjs/data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

comparatorFn is not a function - updateMany doesn't support 'where', expects 'which' v0.5.0

VickyKoblinski opened this issue · comments

Hey, I see that recently which was replaced with where. I have the latest version of this mswjs/data (v0.5.0) from npm and when I try using where in updateMany I get:

TypeError: comparatorFn is not a function

Changing where to which has resolved my problem for now :)

Hey, @VickyKoblinski.

Could you please share your updateMany call? The error you're describing hints that there's an invalid comparator being used (equals/gte/lt/etc.). If you share your usage I can try to help you solve the problem.

I confirm that version 0.5.0 expects and properly handles the where property in all model operations.

Here's an integration test for the updateMany method that uses where and successfully passes:

const updateMultiUsers = db.user.updateMany({
where: {
role: {
equals: 'Auditor',
},
},
data: {
firstName(firstName) {
return firstName.toUpperCase()
},
role(role, user) {
return user.firstName === 'John' ? 'Writer' : role
},
},
})!

Please ensure you're using the latest @mswjs/data version. You can do so by:

$ npm ls @mswjs/data

Or just update to the latest published version by:

$ npm install @mswjs/data@latest -D
# or
$ yarn add @mswjs/data@latest