Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 881 Bytes

getting-all-docs.md

File metadata and controls

23 lines (16 loc) · 881 Bytes

Getting all documents in a Collection

To get all the documents in a collection use the <Collection-Name>.all() method. Let's assume we have a collection called Letters. To get all the document in this collection run the following code.

Letters.all()

Keep in mind that <Collection-Name>.all() method makes a complete scan of the collection. You can also chain <Collection-Name>.all() with other Collection methods.

For instance if you want to get all the users who's age is greater than 10 you can chain a where() function with all() function. Following example code demostrates tis.

User.all().where(.age > 10)

You can keep adding multiple chains to this document. Following is an example to get all the users who are over 18 and has Picard as their lastname.

User.all()
  .where(.age > 10)
  .where(.lastname == 'Picard')