data icon indicating copy to clipboard operation
data copied to clipboard

Query (findMany, findFirst) ignores Array type fields.

Open zorgick opened this issue 3 years ago • 0 comments

It seems like models, that have a field with an Array type, cannot be queried.

A simple model, where roles field is an array of numbers:

const db = factory({
  user: {
    id: primaryKey(() => faker.datatype.uuid()),
    name: () => faker.name.fullName(),
    age: () => faker.datatype.number(),
    roles: () => faker.helpers.arrayElements([1, 2, 3, 4])
  }
});

is ignored by findMany query:

const usersRoleSubset = db.user.findMany({
  where: {
    roles: {
      // no matter, which query (notIn, between) to use arrays are ignored
      in: [2, 3]
    }
  }
});

A reproducable example can be found here: https://codesandbox.io/s/flamboyant-shadow-rmb5gk?file=/src/index.js

zorgick avatar Nov 15 '22 16:11 zorgick