Skip to content

Commit

Permalink
Add find and findAll API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chipotle committed Feb 15, 2016
1 parent 452a34f commit d06fa85
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
31 changes: 31 additions & 0 deletions api/collection-find.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
layout: api
title: Collection.find()
---

# Method

{% apibody %}
Collection.find(integer | object)
{% endapibody %}

# Description

Retrieve a single document from a Collection.

The `find` method may be called with either a key-value pair to match against (e.g., `{name: "agatha"}` or an integer (an `id` value to look up).

```
// get the first message from Bob
messages.find({from: "bob"});
// get the message with ID 101
messages.find({id: 1});
// because the id field contains integers, we can use a shorthand
messages.find(101);
```

Also see: [Collection.findAll][cfa]

[cfa]: /api/collection-findall/
28 changes: 28 additions & 0 deletions api/collection-findall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
layout: api
title: Collection.findAll()
---

# Method

{% apibody %}
Collection.findAll(object[, object, ...])
{% endapibody %}

# Description

Retrieve multiple documents from a Collection.

The `findAll` method can be called with one or more key-value pairs to match against (e.g., `{email: "[email protected]"}`. Every document that matches the pairs will be returned in a list. (If no documents match, an empty list, `[]`, will be returned.)

```
// get all messages from Bob, Agatha and Dave
messages.findAll({from: "bob"}, {from: "agatha"}, {from: "dave"});
// get all messages from Jane and all messages with a high priority
messages.findAll({from: "jane"}, {priority: "high"});
```

Also see: [Collection.find][cf]

[cf]: /api/collection-find/

0 comments on commit d06fa85

Please sign in to comment.