NatLibFi / marc-record-js

MARC record implementation in JavaScript
MIT License
6 stars 1 forks source link

Filtering fields by specified tag and indicators #17

Open smjwsk opened 4 years ago

smjwsk commented 4 years ago

I noticed that it is currently only possible to select fields by a given tag and filter these selected fields on the basis of its subfields.

When working with marc-records we found it a frequent requirement to narrow down on basis of indicators. Here, we would have expected one of the given parameters to getFields or containsFieldWithValue to provide this functionality.

On closer inspections the parameters of getFields in the current implementation are divided in field selection and querying subfields:

given above analysis, I would expect the first parameter to provide functionality to narrow down the fields on basis of the fields properties to consider for optional subfield querying.

I propose to extend the tag parameter by allowing to pass an object as first parameter for field selection. This may well be achieved by retaining the current api. The idea is to pass an object with properties that are all tested against each individual field. In case a string is passed, the previous behaviour is retained. In case the argument is neither of type string or object (not null) an empty array is returned.

Example:

record.getFields({tag: '856', ind1: '4', ind2: '1'}); 

should yield this field if part of the record:

[{
              tag: '856', ind1: '4', ind2: '1', subfields: [
                {code: 'a', value: 'Example'},
                {code: 'u', value: 'http://example.com/object'}
              ]
}]

but still

record.getFields('245')

would work.

Are you open for pull/merge requests? I'd be happy to contribute what I have so far.

smjwsk commented 3 years ago

@natlibfi-arlehiko @ammsalme as you are most recently and most active in this repo. Is there any interest?

smjwsk commented 2 years ago

@natlibfi-koskimim thanks for putting this on the todo list. As stated above. Reach out if contributions are welcome

natlibfi-koskimim commented 2 years ago

Hi!

Yes, we are trying to find some time & resource to maintain marc-record-js 🙂 Sadly, it is just preliminary effort of few coders at the moment, but hopefully our entire organization some day understands the great value of maintenance and providing features needed by users 🙂

All the best,

Markus


Lähettäjä: Stefan Majewski @.> Lähetetty: perjantai 27. toukokuuta 2022 15.10 Vastaanottaja: NatLibFi/marc-record-js @.> Kopio: Koskimies, Markus J @.>; Mention @.> Aihe: Re: [NatLibFi/marc-record-js] Filtering fields by specified tag and indicators (#17)

@natlibfi-koskimimhttps://github.com/natlibfi-koskimim thanks for putting this on the todo list. As stated above. Reach out if contributions are welcome

— Reply to this email directly, view it on GitHubhttps://github.com/NatLibFi/marc-record-js/issues/17#issuecomment-1139559114, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AT6DJDKOEJTPO2YMJOC4HBDVMC3TVANCNFSM4SEXEXJQ. You are receiving this because you were mentioned.Message ID: @.***>