adminjs-prisma icon indicating copy to clipboard operation
adminjs-prisma copied to clipboard

isArray: Property method

Open GaussianWonder opened this issue 1 year ago • 0 comments

The current Property class does not implement the isArray method which causes it to always return false.

This results in data type misinterpretation in lists.

It is fixable by manually overriding the type in the resource options, however, it still makes it very hard to implement custom filtering options inside the list action.

What fails for me is the resource.find call which eventually tries to convertFilter.

if (['boolean', 'number', 'float', 'object', 'array'].includes(filter.property.type())) {
  // <- reaching this step when filter.property.isArray() === true will make it easier to write custom filtering options for array properties.
  where[name] = safeParseJSON(filter.value);
}

If all these changes were to be applied, one could simply:

onChange(props.property.path, JSON.stringify(prismaWhereClauseCompatibleWithArrayDataType));

inside custom filter property components.

GaussianWonder avatar Oct 03 '24 13:10 GaussianWonder