Skip to content

More flexibility with array query operators #167

@Xemiru

Description

@Xemiru

As an example of what does work, you can easily filter through items when your target is a single field inside an array object element -- here's a query that asks for all armor pieces with at least one rank 4 decoration slot.

armor?q={"slots.rank": 4}&p={"slots.rank": true}

Can't ask much about fields holding arrays of non-object values

Here's a few different ways of asking for all weapons who support ammo and have at least one ammo type with a capacity of 3 at any level (all of which fail).

weapons?q={"ammo.capacities": 3}&p={"ammo": true}                    // empty response..
weapons?q={"ammo.capacities": { "$eq": 3 }}&p={"ammo": true }        // empty response..
weapons?q={"ammo.capacities": { "$contains": 3 }}&p={"ammo": true }  // Unrecognized operator: $contains

weapons?q={"ammo.capacities": { "$size": 3 }}&p={"ammo": true }      // $size is the only op that works -- not that it helps in what we wanted to do here

Here's a more likely scenario: ask for all bows that support the sleep coating.

weapons?q={"coatings": "sleep"}                  // empty response..
weapons?q={"coatings": {"$contains": "sleep"}}   // Unrecognized operator: $contains

Cannot ask about specific array indices

Let's define two ideas of sharpness in the context of how it's stored in the database: base sharpness and potential sharpness.

Base sharpness is a weapon's original sharpness values -- sharpness at Handicraft level 0.
Potential sharpness is a weapon's maximum possible sharpness weapons -- Handicraft level 5.
Within weapon data, this is stored in indices 0 and 5 of the durability field, respectively. As of writing, there doesn't seem to be an obvious way to query for data at a specific array index.

The queries below intend ask for weapons with a base white sharpness of 40, then for weapons with a potential white sharpness of 90.

weapons?q={"durability.0.white": { "$gte": 40 }} // Unknown field: durability.0.white
weapons?q={"durability.5.white": { "$gte": 90 }} // Unknown field: durability.5.white

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions