MCPcopy Create free account
hub / github.com/loopbackio/loopback-next / fields

Method fields

packages/filter/src/query.ts:581–601  ·  view source on GitHub ↗

* Describe what fields to be included/excluded * @param f - A field name to be included, an array of field names to be * included, or an Fields object for the inclusion/exclusion

(...f: (Fields<MT> | Extract<keyof MT, string>)[])

Source from the content-addressed store, hash-verified

579 * included, or an Fields object for the inclusion/exclusion
580 */
581 fields(...f: (Fields<MT> | Extract<keyof MT, string>)[]): this {
582 if (!this.filter.fields) {
583 this.filter.fields = {};
584 } else if (Array.isArray(this.filter.fields)) {
585 this.filter.fields = this.filter.fields.reduce(
586 (prev, current) => ({...prev, [current]: true}),
587 {},
588 );
589 }
590 const fields = this.filter.fields;
591 for (const field of f) {
592 if (Array.isArray(field)) {
593 field.forEach(i => (fields[i] = true));
594 } else if (typeof field === 'string') {
595 fields[field] = true;
596 } else {
597 Object.assign(fields, field);
598 }
599 }
600 return this;
601 }
602
603 private validateOrder(order: string) {
604 assert(order.match(/^[^\s]+( (ASC|DESC))?$/), 'Invalid order: ' + order);

Callers 4

filterBuilderHelperFunction · 0.95
query.unit.tsFile · 0.80

Calls

no outgoing calls

Tested by 1

filterBuilderHelperFunction · 0.76