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

v4.1.1 - useFind - No Results if query param result is populated #155

Open
palmtown opened this issue Dec 10, 2023 · 1 comment
Open

v4.1.1 - useFind - No Results if query param result is populated #155

palmtown opened this issue Dec 10, 2023 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@palmtown
Copy link

Hello Community,

I've found an issue with using useFind. In short, when executing the code in Exhibit 1, feathers-pinia successfully queries my backend server which returns the results. However, the messages$.total variable shows the correct total, however, $messages.data is empty.

After debugging, I've found the issue and it is with the findInStore method that executes as part of the useFind function. In short, when I query using user=userId as shown in Exhibit 1, and on the backend I populate the user variable with the user's object, findInStore fails to find the data in the local store as user=userId doesn't match the returned data. In the returned data the user is now popluated with an object rather than a string (e.g. user={_id: "someid"...} opposed to user=userId).

Also, I tried altering the query with {query: {user: {_id: "some_id"}}, however, that doesn't work and findInStore is unable to match results using this query.

Any suggestions?

Exhibit 1
`
const { api } = useFeathers()

const params = computed(() => {
return { query: { user: props.userId } }
})
const messages$ = api.service('messages').useFind(params, { paginateOn: 'hybrid' })
`

Note that this issue is similar to #142 however, in that issue, no parameters are passed in the query. Whereas in this issue, the problem is passing parameters to the query that changes on the backend due to populating the variable.

@marshallswain
Copy link
Owner

I should document that useFind is only intended to work if your frontend and backend data structures match. There's no way to automatically configure two separate, custom data structures. In this case, you'll need to use service.find and service.findInStore manually.

@marshallswain marshallswain self-assigned this Jan 22, 2024
@marshallswain marshallswain added the documentation Improvements or additions to documentation label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants