Class: Taro::Types::ObjectTypes::PageWithTotalCountType
- Inherits:
-
PageType
- Object
- Struct
- BaseType
- Taro::Types::ObjectType
- ResponseType
- PageType
- Taro::Types::ObjectTypes::PageWithTotalCountType
- Defined in:
- lib/taro/types/object_types/page_with_total_count_type.rb
Overview
This is an expanded ‘PageType` that adds a `total_count` field to show the total number of records in the paginated relation. It is not recommended for very large relations where counting might be slow.
Usage:
-
‘returns code: :ok, page_with_total_count_of: ’UserType’‘
-
‘UserType.page_with_total_count.render(User.all, after: params)`
The gem rails_cursor_pagination must be installed to use this.
Constant Summary
Constants included from Shared::OpenAPIFormat
Shared::OpenAPIFormat::OPENAPI_INTEGER_FORMATS, Shared::OpenAPIFormat::OPENAPI_NUMBER_FORMATS, Shared::OpenAPIFormat::OPENAPI_STRING_FORMATS
Constants included from Shared::OpenAPIType
Shared::OpenAPIType::OPENAPI_TYPES
Instance Attribute Summary
Attributes included from Shared::ItemType
Attributes inherited from BaseType
Attributes included from Shared::AdditionalProperties
Attributes included from Shared::Deprecation
Class Method Summary collapse
Methods inherited from PageType
Methods included from Shared::ItemType
Methods inherited from ResponseType
Methods included from Shared::Fields
Methods included from Shared::ObjectCoercion
#coerce_input, #coerce_response
Methods included from Shared::CustomFieldResolvers
Methods included from Shared::AdditionalProperties
#additional_properties?, #inherited
Methods included from Shared::DerivedTypes
#define_derived_type, #derived_types, map
Methods included from Shared::Description
Methods included from Shared::Equivalence
#equal_properties?, #equivalent?
Methods included from Shared::Name
Methods included from Shared::OpenAPIFormat
#inherited, #openapi_format, #openapi_format=
Methods included from Shared::OpenAPIName
#default_openapi_name, #openapi_name, #openapi_name=
Methods included from Shared::OpenAPIType
#inherited, #openapi_type, #openapi_type=
Methods included from Shared::Rendering
#last_render, #last_render=, #render, #used_in_response
Methods included from Shared::TypeClass
Methods included from Shared::Errors
#coerce_error_message, #input_error, #response_error
Methods included from Shared::Caching
#cached_coerce_response, included
Class Method Details
.default_openapi_name ⇒ Object
21 22 23 |
# File 'lib/taro/types/object_types/page_with_total_count_type.rb', line 21 def self.default_openapi_name "#{item_type.openapi_name}_PageWithTotalCount" end |
.derive_from(from_type) ⇒ Object
12 13 14 15 |
# File 'lib/taro/types/object_types/page_with_total_count_type.rb', line 12 def self.derive_from(from_type) super field(:total_count, type: 'Integer') end |
.paginate(relation) ⇒ Object
17 18 19 |
# File 'lib/taro/types/object_types/page_with_total_count_type.rb', line 17 def self.paginate(relation, **) super.merge(total_count: relation.count) end |