Search

The search method performs a text-based search across records in the collection.

Configuration Example

# spec.yml
name: Collection Name
methods:
  search:
    parametersSchema:
      type: object
      properties:
        searchFields:
          type: array
          items:
            type: string
            enum: ["name", "email", "phone"]
          default: ["name", "email"]
          description: Fields to search in

Implementation Examples

module.exports = async ({ query, cursor, credentials, parameters }) => {
  const response = await makeApiRequest({
    method: "GET",
    path: "/api/contacts/search",
    query: {
      q: query,
      limit: 50,
      offset: cursor || 0,
    },
    credentials,
  })

  return {
    records: response.data,
    cursor: response.hasMore ? String((cursor || 0) + 50) : undefined,
  }
}

Input

PropertyTypeDescription
querystringThe search query string
cursorstringPagination cursor from previous request
credentialsobjectAuthentication credentials
parametersobjectMethod-specific parameters

Return Value

PropertyTypeDescription
recordsarrayArray of matching records
cursorstringCursor for next page (optional)