Skip to content

Commit

Permalink
document count method
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Nov 29, 2019
1 parent 0a2b44d commit e9258ae
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/photon/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Photon is a type-safe database client auto-generated based on your [data model d

- [Overview](#overview)
- [CRUD](#crud)
- [Aggregations](#aggregations)
- [Field selection](#field-selection)
- [Relations](#relations)
- [Raw databases access](#raw-database-access)
Expand Down Expand Up @@ -79,6 +80,19 @@ async function main() {

Note that the name of the `users` property is auto-generated using the [`pluralize`](https://github.com/blakeembrey/pluralize) package.

## Aggregations

In addition to CRUD operations, Photon.js also allows for [_aggregation_ queries](https://github.com/prisma/photonjs/issues/5).

### `count`

To return the number of elements in a list, you can the `count()` method on any model property on your `Photon` instance, for example:

```ts
const userCount = await photon.users.count()
// userCount = 42
```

## Field selection

This section explains how to predict and control which fields of a model are returned in a Photon API call.
Expand Down Expand Up @@ -360,6 +374,21 @@ const deletedUserCount = await photon.users.deleteMany({
})
```

### `count`

Returns the number of elements in a list as a value of type `number`.

#### Options

The `count()` method doesn't take any input arguments.

#### Examples

```ts
const userCount = await photon.users.count()
// userCount = 42
```

## Filtering

The Photon.js API offers filtering options for constraining the items that are returned from API calls that return lists via the `where` argument.
Expand Down

0 comments on commit e9258ae

Please sign in to comment.