Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to retrieve repetition fields #5

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

contip
Copy link

@contip contip commented Oct 2, 2024

This PR builds upon the work submitted by @qinqinghai in the abandoned PR #3. It implements the retrieval of repeating fields, which can be a critical feature when working with filemaker databases that use this uncommon field type.

New functionality:

  • Retrieval of all repetitions for a repeating field
  • Retrieval of a specific repetition for a repeating field
  • Support for both regular and binary repeating fields

Changes:

  • Refactored the new functions fetchFieldValue (to support returning specific repetitions as well as all) and fetchBinaryFieldValue (to adopt styling standards)
  • Removed the tabCleanedJson as requested by @DASPRiD

Note that this tabCleanedJson was added by @qinqinghai most likely in order to pass the laxParsing tests in connection.ts, and removing it caused the should error with non encoded newlines without lax parsing in JSON response to fail. As such, I went ahead and edited that test to expect either Unexpected token or Bad control character in string literal.

  • Refactored the unit tests for fetchFieldValue and fetchBinaryFieldValue to respond to @DASPRiD 's requests, as well as added new unit tests for the fetchFieldValue individual repetition fetch functionality
  • Updated README.md to document the new functionality

Example usage:

// Fetch all repetitions of a field
const allRepetitions = await userTable.fetchFieldValue(1, 'phoneNumbers');
console.log('All phone numbers:', allRepetitions);

// Fetch a specific repetition (e.g., the second repetition, index 1)
const secondPhoneNumber = await userTable.fetchFieldValue(1, 'phoneNumbers', 1);
console.log('Second phone number:', secondPhoneNumber);

// For binary repeating fields
const allPhotos = await userTable.fetchBinaryFieldValue(1, 'photos');
console.log('All photos:', allPhotos);

const thirdPhoto = await userTable.fetchBinaryFieldValue(1, 'photos', 2);
console.log('Third photo:', thirdPhoto);

This PR focuses on the retrieval of repeating fields and does not include functionality for creating or updating repeating fields, although this is something that I will probably look into in the future. Also note that in the changes to the documentation, the new features has been marked as experimental, acknowledging the fact that the implementation may evolve in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants