Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/coverage
pkg

lib/.DS_Store
lib/parse/.DS_Store
.DS_Store

.bundle

Expand Down
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ parse-ruby-client lets you interact with Parse using Ruby. There are many uses.
```ruby
require 'parse-ruby-client'

Parse.init :application_id => "<your_app_id>",
:api_key => "<your_api_key>",
:quiet => true | false
Parse.init :application_id => "<your_app_id>", # required
:api_key => "<your_api_key>", # required
:quiet => true | false # optional, defaults to false
```

[![Gem Version](https://badge.fury.io/rb/parse-ruby-client.png)](http://badge.fury.io/rb/parse-ruby-client)
[![Gem Version](https://img.shields.io/gem/v/parse-ruby-client.svg)](http://badge.fury.io/rb/parse-ruby-client)

[![Build Status](https://travis-ci.org/adelevie/parse-ruby-client.png?branch=master)](https://travis-ci.org/adelevie/parse-ruby-client)
[![Travis](https://img.shields.io/travis/adelevie/parse-ruby-client.svg)](https://travis-ci.org/adelevie/parse-ruby-client)

[![Code Climate](https://codeclimate.com/github/adelevie/parse-ruby-client.png)](https://codeclimate.com/github/adelevie/parse-ruby-client)
[![Code Climate](https://img.shields.io/codeclimate/github/adelevie/parse-ruby-client.svg)](https://codeclimate.com/github/adelevie/parse-ruby-client)

**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

Expand Down Expand Up @@ -572,6 +572,15 @@ scores = Parse::Query.new("GameScore").tap do |q|
end.get
```

You can use `keys` to only get specified fields back. `objectId`, `createdAt`, and `updatedAt` are always returned, and other fields are supplied as a comma separated string.

```ruby
scores = Parse::Query.new("GameScore").tap do |q|
q.keys = "score,name"
end.get
```


All of these parameters can be used in combination with each other.

### Queries on Array Values
Expand Down Expand Up @@ -678,7 +687,7 @@ You can issue a query with multiple fields included by passing a comma-separated

```ruby
comments = Parse::Query.new("Comment").tap do |q|
q.include("post,author")
q.include = "post,author"
end.get
```

Expand Down
115 changes: 115 additions & 0 deletions fixtures/vcr_cassettes/test_keys.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/parse/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Query
attr_accessor :skip
attr_accessor :count
attr_accessor :include
attr_accessor :keys

def initialize(cls_name)
@class_name = cls_name
Expand Down Expand Up @@ -141,7 +142,7 @@ def get
end
query = { "where" => where_as_json.to_json }
set_order(query)
[:count, :limit, :skip, :include].each {|a| merge_attribute(a, query)}
[:count, :limit, :skip, :include, :keys].each {|a| merge_attribute(a, query)}
Parse.client.logger.info{"Parse query for #{uri} #{query.inspect}"} unless Parse.client.quiet
response = Parse.client.request uri, :get, nil, query

Expand Down
15 changes: 15 additions & 0 deletions test/test_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ def test_include
end
end

def test_keys
VCR.use_cassette('test_keys', :record => :new_episodes) do
post = Parse::Object.new "Post"
post['title'] = 'foo'
post['name'] = 'This is cool'
post.save

q = Parse::Query.new "Post"
q.eq('objectId', post.parse_object_id)
q.keys = 'title'

assert_equal false, q.get.first.include?('name')
end
end

def test_or
#VCR.use_cassette('test_or', :record => :new_episodes) do
foo = Parse::Object.new "Post"
Expand Down