Skip to content

Does this work with nested fields and related models? #19

@dschreij

Description

@dschreij

Hi there. I have a model which includes relationships. I include relationship data with the .with() function.
Even though fuse says it supports search of nested fields using the dot notation (https://fusejs.io/examples.html#nested-search), the neste fields of my model do not seem to be picked up.

const inquiries = computed(() => {
  const query = Inquiry.query()
    .has('shipment')
    .with('shipment.origin|destination')
    .with('user')
    .orderBy('created_at', 'desc')
  if (searchterm.value?.length > 2) {
    query.search(searchterm.value, {
      keys: ['status', 'shipment.hubspot_deal_id', 'user.first_name', 'user.last_name']
    })
  }
  return query.get()
})

If I search the status field. It appears to be working correctly. But if I try to search a user by first name or last name, the search result turns up empty.

So I guess my questions are:

  • Does this plugin support the situation above, in which one wants to search nested fields, that consist of related models included using with()?
  • When is the search executed? Is this before the .with() functions have successfully executed, or after?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions