esapiserver 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d29610e65e8c9fd785f760e9996c5bbcd43d291a
4
- data.tar.gz: 3934d0c162adfdf35952d5e63afe4ff068082ddf
3
+ metadata.gz: 10db36d732326c30b1ea10d9a4508ae74d69cbed
4
+ data.tar.gz: 20b8649043caa2e7be49d4ac46d8096a5a898a2e
5
5
  SHA512:
6
- metadata.gz: 7f774209bcf0cdf3db811011d47221d9f24dbe076ad04ad93d8d491f821a2fedd9b338bfb562ef49fb9a7728fc9f289ddaad51933cd84cb6d5149ef025dca850
7
- data.tar.gz: 5b5989832c12b42cef4255ddb2360ce4e4ee3d3d7dad8bafb3c017ea6d9a68010c5e8525b3e84c9fa73632551abf8b8af0e38889b355c9c9108cc7628d2b94a4
6
+ metadata.gz: 262b1ee728134ed4e3e2295b85c32e4a8a91473b5538395f60f58e082900cf53a298e43f1afffde663eeb871ce52994bce7410d5ee53357576c3b4123e165128
7
+ data.tar.gz: 8612b62082502e511729ea1c0ad2ae963041ab0e11de12344a55eb7eb2963f4084d0b68cadb1bf6dea3575c79e5bba7181ef6077adb6f0e2633732e57c631e86
@@ -79,15 +79,14 @@ module Esapiserver
79
79
  if request.query_string.empty?
80
80
  result = collection.find.to_a.map{|t| fromBsonId(t, params[:model])}.to_json
81
81
  else
82
- if request.query_string.include? 'ids[]' or request.query_string.include? 'ids%5B%5D' #don't know why it does not get unescaped
82
+ if request.query_string.include? 'ids[]' or request.query_string.include? 'ids%5B%5D'
83
83
  ids = []
84
-
85
84
  if request.query_string.include? '&'
86
85
  queries = request.query_string.split('&')
87
86
  queries.each do |q|
88
87
  key, value = q.split('=')
89
- if key != 'ids[]' and key != 'ids%5B%5D' #check to see if all the keys match
90
- throw 'multiple query parameters not supported yet, except for _ids[]='
88
+ if key != 'ids[]' and key != 'ids%5B%5D'
89
+ throw 'multiple query parameters that also have _ids[]= parameters not supported yet'
91
90
  end
92
91
  ids << toBsonId(value)
93
92
  end
@@ -97,7 +96,14 @@ module Esapiserver
97
96
  end
98
97
  query = {"_id" => { "$in" => ids }}
99
98
  elsif request.query_string.include? '&'
100
- throw 'multiple query parameters not supported yet, except _ids[]='
99
+ conditions = []
100
+ queries = request.query_string.split('&')
101
+ queries.each do |q|
102
+ key, value = q.split('=')
103
+ conditions << {modelName(params[:model]) + "." + key => value}
104
+ end
105
+ query = {"$and" => conditions }
106
+ puts query
101
107
  else
102
108
  key, value = request.query_string.split('=')
103
109
  query = {modelName(params[:model]) + "." + key => value}
@@ -1,3 +1,3 @@
1
1
  module Esapiserver
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -41,7 +41,7 @@ describe 'esapiserver that' do
41
41
  end
42
42
 
43
43
  #http://127.0.0.1:4567/api/focusareas?ids%5B%5D=53d7781819cfd232f4000085&ids%5B%5D=53d778e319cfd232f4000087
44
- it 'returns a list of models that matches a specific query' do
44
+ it 'returns a list of models that matches a list of ids' do
45
45
  #create another post
46
46
  payload = '{"post": {"name": "test1"}}'
47
47
  post '/api/posts', payload, "CONTENT_TYPE" => "application/json"
@@ -61,6 +61,10 @@ describe 'esapiserver that' do
61
61
  #TODO should check to see if it is parsable by json
62
62
  end
63
63
 
64
+ it 'returns a list of models that matches a specific query' do
65
+ pending
66
+ end
67
+
64
68
  #http://localhost:4567/api/posts?name=test1
65
69
  it 'returns a model with a specific key/value' do
66
70
  get '/api/posts?name=test1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esapiserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Miles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-02 00:00:00.000000000 Z
11
+ date: 2014-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler