Skip to content

Query With Custom Sorting, Occurrences In String Array #1586

@ljs19923

Description

@ljs19923

Hi,
I want to know if it's possible to sort my query in this way.

My className is called "Shop"

Each shop have a field called "campaignsDateString" who is an array of String like that :
["8/28/2020", "8/30/2020", "8/31/2020", "8/31/2020","9/1/2020"]

On my query I want to get all shops who have campaigns for specifics dateString, who is also an array of String
["8/28/2020", "8/30/2020]

So on my query I have this constraint
query.whereKey("campaignsDateString", containedIn:["8/28/2020", "8/29/2020])

if for example I have 2 shops like this
SHOP1
campaignsDateString = ["8/28/2020", "8/30/2020", "8/31/2020", "8/31/2020","9/1/2020"]

SHOP2
campaignsDateString = ["8/28/2020", "8/28/2020","8/28/2020", "8/28/2020","8/28/2020", "8/28/2020"]

I want to sort my results by occurrences of campaignsDateString matching my array ["8/28/2020", "8/29/2020]
The second shop have 5 times "8/28/2020" and the first shop only one time, so i want to get Shop 1 in first.

If someone have an idea of how to do that.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions