> For the complete documentation index, see [llms.txt](https://docs.wirebootstrap.com/indexed-db/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wirebootstrap.com/indexed-db/collection.md).

# Collection

The WireBootstrap IndexedDB Connector's service provider can be used as a collection into IndexedDB database stores.  The service provider contains methods for maintaining stores using a key into the collection.

The service provider class constructor takes the key name as the first parameter and optionally an array of data to set into IndexedDB to be maintained using the collection.

The following example creates a new instance of the service provider directly.  It specifies the data to be an array of `fruits` with the `name` field being the key into the collection.

```javascript
const fruits = [
  { name: "grapes", color: "green"},
  { name: "bananas", color: "yellow"},
  { name: "apples", color: "red"},
];

const col = new wire.indexedDb("name", fruits);
```

## GetAll

To retrieve all objects from the store created above in IndexedDB, use the `getAll` method.

```javascript
...
const fruits = await col.getAll();
```

## Get

To pull a single object from the IndexedDB store, use the `get` method specifying the value for the key into the collection.

```javascript
...
const fruit = await col.get("grapes");
```

## Put

To add an object to the IndexedDB store, use the `put` method with the object.

```javascript
...
const fruit = { name: "oranges", color: "orange"};
await col.put(fruit);
```

## Delete

To remove an object from the IndexedDB store, use the `delete` method specifying the key value for the object to be removed.

```javascript
...
await col.delete("bananas");
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wirebootstrap.com/indexed-db/collection.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
