Skip to content

Commit 79abd8a

Browse files
Merge pull request #15 from SlicingDice/update-exists-entity
Update exists_entity method
2 parents 4b08fb5 + 611f6c2 commit 79abd8a

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Updated
44
- Update API errors code
5+
- Update `exists_entity()` to receive `table` as parameter
56

67
## [1.0.0]
78
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ puts client.insert(insert_data)
230230
}
231231
```
232232

233-
### `exists_entity(ids)`
234-
Verify which entities exist in a database given a list of entity IDs. This method corresponds to a [POST request at /query/exists/entity](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-query-exists-entity).
233+
### `exists_entity(ids, table)`
234+
Verify which entities exist in a table (uses `default` table if not provided) given a list of entity IDs. This method corresponds to a [POST request at /query/exists/entity](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-query-exists-entity).
235235

236236
#### Request example
237237

lib/rbslicer.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,10 @@ def top_values(query)
274274
# Public: Check if a list of entities exists in SlicingDice API
275275
#
276276
# ids(Array) - A Array with ids to be checked
277+
# table(String) - In which table entities check be checked
277278
#
278279
# Returns a Hash with ids that exists and that don't exits
279-
def exists_entity(ids)
280+
def exists_entity(ids, table=nil)
280281
base_url = wrapper_test()
281282
url = base_url + METHODS[:query_exists_entity]
282283
if ids.length > 100
@@ -286,6 +287,9 @@ def exists_entity(ids)
286287
query = {
287288
'ids' => ids
288289
}
290+
if table.nil?
291+
query['table'] = table
292+
end
289293
make_request(url, "post", 0, data=query)
290294
end
291295

0 commit comments

Comments
 (0)