---
title: "Collection"
description: "The query surface of one collection."
url: "https://pitlane.tools/package/content/interface/Collection"
---

# Collection

```ts
import type { Collection } from "@pitlane/content";
```

The query surface of one collection.

## Type Parameters

### Name

`Name` _extends_ `string`

### Data

`Data`

## Methods

### getCollection()

```ts
getCollection(filter?): Promise<Entry<Data>[]>;
```

Every entry, sorted by id, keeping only those `filter` returns truthy for when one is given.

#### Parameters

##### filter?

(`entry`: [`Entry`](https://pitlane.tools/package/content/interface/Entry.md)\<`Data`>) => `unknown`

#### Returns

`Promise`\<[`Entry`](https://pitlane.tools/package/content/interface/Entry.md)\<`Data`>\[\]>

---

### getEntry()

```ts
getEntry(id): Promise<Entry<Data> | undefined>;
```

The entry with this id, or the one a [Reference](https://pitlane.tools/package/content/interface/Reference.md) into this collection points at. Resolves to `undefined` when there is none.

#### Parameters

##### id

`string` | [`Reference`](https://pitlane.tools/package/content/interface/Reference.md)\<`Name`>

#### Returns

`Promise`\<[`Entry`](https://pitlane.tools/package/content/interface/Entry.md)\<`Data`> | `undefined`>
