Support querying through one-to-many relations
kettanaito opened this issue · comments
const db = factory({ user: { post: manyOf('post') } })
// Returns the list of users who have at least one "post"
// with a title matching one of the provided titles.
db.user.findMany({
which: {
post: {
title: {
in: ['First post', 'Second post']
}
}
}
})
Expected behavior
// Given these users
db.user.create({
id: 1,
posts: [db.post.create({ title: 'First post' })]
})
db.user.create({
id: 2,
posts: [db.post.create({ title: 'Second post' }), db.post.create({ title: 'Third post' })]
})
db.user.create({
id: 3,
posts: [db.post.create({ title: 'Fourth post' })]
})
// Should return the following users:
[1, 2]
Current behavior
Failed to find a comparator for the value "[...]"