mswjs / data

Data modeling and relation library for testing JavaScript applications.
https://npm.im/@mswjs/data
MIT License
823 stars 52 forks source link

Can `findFirst()` support the `where` parameter as function? #256

Open cp3hnu opened 1 year ago

cp3hnu commented 1 year ago

This API like that

model.findFirst({
  where: (item) => return true
});

It will be more flexible.

kettanaito commented 1 year ago

Hey, @cp3hnu. Thanks for proposing this!

If I remember the context correctly, the intention was to have all the queries serializable to string so that we could synchronize occurring operations between different tabs. That's still relevant for the current version of the library but may not be as relevant for the future releases.

The proposal itself makes sense. Let's keep it in mind, I shall revisit this when I'm working on this library again.