SkyGear CMS: Sorting of Reference Field


#1

I am trying to update the Skygear CMS using the cms-config.yaml file

below is the code

show:
label: Offers
fields:
- name: packages
type: EmbeddedReference
default_sort:
name: night_count
ascending: false
label: Packages
reference_via_back_reference: package
reference_from_field: offer_id

  reference_fields:
    - name: night_count
      type: Integer
    - type: _created_at
    - type: _updated_at
  reference_delete_action: delete-record

below ‘show’ I have field with name ‘packages’ which has type ‘EmbeddedReference’. Now I want to sort the ‘packages’ as per the added date, I have tried default_sort but it is not working(might only work on lists). Is there a way to sort the field. Any help will be highly appreciated.

Working environment: WEB

Moreover Can I get the documentation for all the tags available for updating the cms-config.yaml file


#2

default_sort is an attribute for record list. In your case, reference_position_field and reference_position_ascending should be the attributes you are looking for.

BTW, EmbeddedReference is not a valid field type in the latest version but embedded_reference_list.

The configuration would look like this:

show:
  label: Offers
  fields:
    - name: packages
      type: embedded_reference_list
      label: Packages
      reference_via_back_reference: package
      reference_from_field: offer_id
      reference_position_field: night_count
      reference_position_ascending: false

      reference_fields:
        - name: night_count
          type: Integer
        - type: _created_at
        - type: _updated_at
      reference_delete_action: delete-record