SearchQuery
MMO.core · 1 symbol · generated 27 Oct 2026
SearchQuery
SearchQuery.js:28The model behind <mmo-search>: a query's filters seen as a list of chips, and back.
- Namespace
MMO.core
Index
| OPERATORS static readonly accessor | ||
| FieldsFromSchema(schema) static async | The fields a collection can be filtered on: its visible properties a chip can describe, in their order, then its search properties that take one text (#[SearchProperty] without a view; label is… | |
| FieldOf(prop, key, parent) static async | The field a property is, its enum loaded, its class looked at: an entity of a collection (its class has an id) is a ref, picked by its label (RefQuery); an embedded one an object, whose … | |
| CollectionOf(prop, instance) static | Where the entities a property points to are listed from: its schema's collection, or the $collection the server gives their class in data/schemas.json (mmo.core's `RepositoryController::getCo… | |
| KindOf(schema) static | ||
| TextFields(fields) static | ||
| MatchField(word, fields) static | The field a typed word names, by its key or its title (case and accents ignored): statut or Statut is the field status titled "Statut". | |
| SuggestFields(word, fields) static | The fields a word being typed could be the start of, best first: those it starts, then those it is in. | |
| NamesOf(field, short) static | ||
| SuggestValues(field, word) static | The values of an enum a typed word could be, best first, by value or by label. | |
| Parse(filters, search) static | Read a query's filters (and search) as the bar shows them. | |
| FlattenAnd(filter) static | The members of a filter's root AND, wherever they sit: {a: 1, b: 2}, {'$and': [{a: 1}, {b: 2}]} and {'$and': [{a: 1}], b: 2} are all [{a: 1}, {b: 2}]. | |
| ConditionsOfItem(item) static | ||
| ConditionsOf(members) static | ||
| TextOf(members) static | ||
| Build(state, textFields) static | Write the bar back as a filter. | |
| ItemOf(cond) static | ||
| SetCondition(state, cond, index) static | Add a condition, in place of the one already on that path -- except two bounds (> and <), which narrow the same path together. | |
| ParseToken(field, raw) static | Read what was typed after field:. | |
| MatchRef(field, text) static | The entity a typed text names, among those whose label is known (AddRefs): the one it is the label of, or the only one whose label holds it. | |
| SuggestRefs(field, word) static | The entities a typed word could be, best first, among those whose label is known. | |
| AddRefs(field, entities) static | Learn the labels of entities a ref field points to (Label shows them, MatchRef finds them). | |
| RefQuery(field, {text = null, uids = null, limit = 20}) static | The query listing the entities of a ref field: those whose label holds a text, or those it does not know the label of yet. | |
| MissingRefs(state, fields) static | ||
| MatchValue(field, text) static | ||
| DateRange(text) static | The days a typed date covers. | |
| Bool(value) static | ||
| Operators(kind) static | The operators the editor offers for a kind of field. | |
| EditorOperator(cond, kind) static | The editor's operator for a condition: Operators. | |
| OperatorLabel(op, kind) static | ||
| Label(field, value) static | ||
| Describe(cond, field) static | What a chip says. | |
| Normalize(value) static | ||
| IsNumericObject(value) static | ||
| List(value) static |
Properties1
OPERATORS
staticreadonlyaccessorSearchQuery.js:30- Type
Array<string>
Methods34
FieldsFromSchema(schema)
staticasyncSearchQuery.js:45The fields a collection can be filtered on: its visible properties a chip can describe, in their order, then its search properties that take one text (#[SearchProperty] without a view; label is the free text's).
| schema | MMO.schemas.Schema | the collection's schema |
| returns | Promise<Object<string, {key: string, title: string, kind: string, values: ?Array | >>} |
FieldOf(prop, key, parent)
staticasyncSearchQuery.js:84The field a property is, its enum loaded, its class looked at: an entity of a collection (its class has an id) is a ref, picked by its label (RefQuery); an embedded one an object, whose properties are fields of their own (adresse/ville).
| prop | MMO.schemas.Schema | |
| key | string | its key in its entity |
| parent = null | ?Object | the object field it is a property of: its path and title come first ("Adresse - Ville") |
| returns | Promise<?Object> | null for a property a chip cannot describe |
CollectionOf(prop, instance)
staticSearchQuery.js:135Where the entities a property points to are listed from: its schema's collection, or the $collection the server gives their class in data/schemas.json (mmo.core's RepositoryController::getCollectionOf). Nothing is guessed: a class no collection holds, or several (an abstract one), has none, and its chip is typed by uid.
| prop | MMO.schemas.Schema | a ref property |
| instance = null | ?MMO.schemas.Schema | the schema of its class |
| returns | ?{collection: string, repository: ?string | } |
KindOf(schema)
staticSearchQuery.js:146| schema | MMO.schemas.Schema | a property's schema |
| returns | ?string | the kind of field it is, null for one a chip cannot describe (an object, a list...) |
TextFields(fields)
staticSearchQuery.js:167| fields | Object | FieldsFromSchema |
| returns | Array<string> | the paths the free text is looked for in |
MatchField(word, fields)
staticSearchQuery.js:178The field a typed word names, by its key or its title (case and accents ignored): statut or Statut is the field status titled "Statut".
| word | string | |
| fields | Object | FieldsFromSchema |
| returns | ?Object | the field, null when the word names none |
SuggestFields(word, fields)
staticSearchQuery.js:197The fields a word being typed could be the start of, best first: those it starts, then those it is in.
| word | string | '' lists them all |
| fields | Object | FieldsFromSchema |
| returns | Array<Object> |
NamesOf(field, short)
staticSearchQuery.js:213| field | Object | |
| short = true | boolean | with the names of a property of an embedded object alone (ville, "Ville") |
| returns | Array<string> | the words that name a field, normalized: its key, what is typed for it, its title |
SuggestValues(field, word)
staticSearchQuery.js:225The values of an enum a typed word could be, best first, by value or by label.
| field | Object | an enum field |
| word | string | |
| returns | Array<*> |
Parse(filters, search)
staticSearchQuery.js:245Read a query's filters (and search) as the bar shows them.
| filters | ?Object | MMO.core.APIRequester#filters |
| search = null | ?Object | MMO.core.APIRequester#search |
| returns | conditions: Array<Object>, any: boolean, text: string, search: ?Object, advanced: Array<Object> | } |
FlattenAnd(filter)
staticSearchQuery.js:288The members of a filter's root AND, wherever they sit: {a: 1, b: 2}, {'$and': [{a: 1}, {b: 2}]} and {'$and': [{a: 1}], b: 2} are all [{a: 1}, {b: 2}].
| filter | * | |
| returns | Array<Object> |
ConditionsOfItem(item)
staticSearchQuery.js:305| item | Object | one path and its value: {age: {'$gte': 18}} |
| returns | ?Array<Object> | its conditions, null when a chip cannot describe it |
ConditionsOf(members)
staticSearchQuery.js:332| members | Array<Object> | the members of an OR |
| returns | ?Array<Object> | one condition per member, null when one of them is not a single condition |
TextOf(members)
staticSearchQuery.js:346| members | Array<Object> | the members of an OR |
| returns | ?string | the free text they look for, when they are the same $regex on every path; null otherwise |
Build(state, textFields)
staticSearchQuery.js:367Write the bar back as a filter.
| state | Object | Parse |
| textFields = [] | Array<string> | the paths the free text is looked for in (TextFields); none when the text goes to a search instead |
| returns | ?Object | {'$and': [...]}, null when there is nothing to filter on |
ItemOf(cond)
staticSearchQuery.js:382| cond | Object | a condition |
| returns | Object | its filter: {status: 'active'}, {age: {'$gte': 18}}... |
SetCondition(state, cond, index)
staticSearchQuery.js:403Add a condition, in place of the one already on that path -- except two bounds (> and <), which narrow the same path together.
| state | Object | Parse |
| cond | Object | |
| index = null | ?number | the condition it replaces, when it is edited rather than added |
| returns | Object | state |
ParseToken(field, raw)
staticSearchQuery.js:430Read what was typed after field:.
| field | Object | FieldsFromSchema |
| raw | string | |
| returns | ?Object | the condition, null when the text is not a value of that field |
MatchRef(field, text)
staticSearchQuery.js:515The entity a typed text names, among those whose label is known (AddRefs): the one it is the label of, or the only one whose label holds it. An uid (mongodb://.../contrats#12) is itself.
| field | Object | a ref field |
| text | string | |
| returns | string | undefined | its uid, undefined when the text names none, or several |
SuggestRefs(field, word)
staticSearchQuery.js:532The entities a typed word could be, best first, among those whose label is known.
| field | Object | a ref field |
| word | string | |
| returns | Array<string> | their uids |
AddRefs(field, entities)
staticSearchQuery.js:551Learn the labels of entities a ref field points to (Label shows them, MatchRef finds them).
| field | Object | a ref field |
| entities | Iterable<Object | string> | Object | what the api answered: {uid, metadata: {title}}, {uid, title}, or a list's links (<uid>;title="...", MMO.core.APIRequester#listOnly) |
| returns | Array<string> | their uids, in their order |
RefQuery(field, {text = null, uids = null, limit = 20})
staticSearchQuery.js:575The query listing the entities of a ref field: those whose label holds a text, or those it does not know the label of yet.
| field | Object | a ref field |
| {text = null, uids = null, limit = 20} = {} | ||
| returns | ?{collection: string, repository: ?string, filters: ?Object, search: ?Object, limit: number | } null without a collection |
MissingRefs(state, fields)
staticSearchQuery.js:592| state | Object | Parse |
| fields | Object | FieldsFromSchema |
| returns | Object<string, Array<string>> | by field, the uids its chips hold whose label is not known yet |
MatchValue(field, text)
staticSearchQuery.js:611| field | Object | an enum field |
| text | string | a value or its label, case and accents ignored; or the start of only one of them |
| returns | * | the value, undefined when the text is none of them |
DateRange(text)
staticSearchQuery.js:624The days a typed date covers.
| text | string | 2026-09-01, 01/09/2026, 1/9/26, 2026-09, 09/2026 or 2026 |
| returns | ?Array<string> | [first, last] as YYYY-MM-DD, null when it is not a date |
Bool(value)
staticSearchQuery.js:655| value | * | |
| returns | ?boolean | null when the value is no boolean |
Operators(kind)
staticSearchQuery.js:672The operators the editor offers for a kind of field. Besides the filter's own: $between, $on (a date's whole day), $set/$empty ($exists), $search (a search property).
| kind | string | |
| returns | Array<string> |
EditorOperator(cond, kind)
staticSearchQuery.js:690The editor's operator for a condition: Operators.
| cond | Object | |
| kind | string | |
| returns | string |
OperatorLabel(op, kind)
staticSearchQuery.js:705| op | string | a filter or an editor operator |
| kind | string | |
| returns | string | how it reads: "contains", "is one of", "after", "≥"... |
Label(field, value)
staticSearchQuery.js:721| field | ?Object | FieldsFromSchema, null for a path the schema does not describe |
| value | * | |
| returns | string | the value as a user reads it: an enum's label, "yes", 01/09/2026... |
Describe(cond, field)
staticSearchQuery.js:745What a chip says.
| cond | Object | |
| field | ?Object | FieldsFromSchema |
| returns | field: string, op: string, value: string | } |
Normalize(value)
staticSearchQuery.js:778| value | * | |
| returns | string | lower case, without accents nor surrounding spaces: what two words are compared on |
IsNumericObject(value)
staticSearchQuery.js:786| value | * | |
| returns | boolean | true for an object whose keys are 0, 1, 2...: a list, as a query string can hand one over |
List(value)
staticSearchQuery.js:796| value | * | |
| returns | Array | the value as a list: itself, its values (IsNumericObject) or [value] |