Should a query hook change data with the content manager

I have a very simple bit code to add a % sign on the end of a number:

export function Moviesx_afterQuery(item, context) {
item.femalePercent = item.femalePercent + ‘%’
return item;
}

And on my site, I do indeed get the desired result - .e.g. 12%

But what surprises me is when I look in the content manager the ‘femalePercent’ now shows with % (together with an ! " The value does not match the field type Number". ), instead of just an interger.

Is this expected behaviour? I only expected the query hook to only apply on the client-side , not when viewing the data in the content manager.

Thanks

I don’t think it does any harm but maybe you’d prefer to use different field names, so it’ll look OK when you load the content manager. something like:

export function Moviesx_afterQuery(item, context) {
item.femalePercentFormat = item.femalePercent + '%';
 return item; }

and use the new field on the front-end page.

Yes, that is a good solution for many situations but some plugins such as the Pro Galleries seem only to be able to access the collection’s fields, not ones generated in JS.

You can also create an empty text field in your collection with field key " femalePercentFormat " and then use my code.

Ta, I’ll give that a try.