@mantlebee/ts-data
    Preparing search index...

    Function projectItems

    • Keeps only the projected fields of the items of a list, as a SELECT of some columns would: every item becomes a new object holding the projected fields it has (a field the item lacks is not added), a field projected twice is kept once, a null or undefined item stays as it is. Without projections, or with an empty list, the items are returned whole. The list and its items are never mutated; the result is always a new array.

      Type Parameters

      • TItem = any

      Parameters

      • items: List<TItem>

        Items to project.

      • Optionalprojections: List<Projection<TItem>>

        Fields to keep; none, or an empty list, for every field.

      Returns List<TItem>

      the projected items, typed as whole items because the readers return them as such; a copy of the list without projections.

      const names = projectItems(users, [{ field: "id" }, { field: "lastName" }]);
      // [{ id: 1, lastName: "Doe" }, ...]