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

# find()

Creates a cursor for a filter that can be used to iterate over results

## Example

```javascript
//find all items in db
db.collection("users").find({}).then(items => {
    console.log(items);
    //output => [{item1...}, {item2...}, {item3...}];
}).catch(error => {
    console.log("error:", error);
});

//find items by filter
db.collection("users").find({
    banned: false,
    accountCreated: "13/02/2023"
}).then(items => {
    console.log(items);
    /*
        items output => [
            {
                _id: "t4m1s8kuw3445ros7zz682no52e9lj91",
                banned: false,
                accountCreated: "13/02/2023",
                example1: "example1",
                example2: "example2",
            },
            {
                _id: "dvf567m6psu73fqhre711133i13ant7m",
                banned: false,
                accountCreated: "13/02/2023",
                example1: "example1",
                example2: "example2",
            }
        ];
    */
}).catch(error => {
    console.log("error:", error);
});
```

## find(\<filter>)

| Parameter | Description                                                                                     |
| --------- | ----------------------------------------------------------------------------------------------- |
| filter    | The filter predicate. If unspecified, then all items in the collection will match the predicate |
