Skip to content

Commit 54b5688

Browse files
Merge pull request #17 from SlicingDice/update-exists-entity
Update existsEntity
2 parents 8459407 + 0926bf7 commit 54b5688

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
### Updated
4+
- Update `existsEntity()` method to receive `table` as parameter
45
- Update Api Errors code
56

67

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ client.insert(insertData).then((resp) => {
265265
}
266266
```
267267

268-
### `existsEntity(ids)`
269-
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).
268+
### `existsEntity(ids, table = null)`
269+
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).
270270

271271
#### Request example
272272

src/slicer.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -573,26 +573,30 @@
573573
*
574574
* @param (array) query - the query to send to Slicing Dice API
575575
*/
576-
countEvent(query){
576+
countEvent(query) {
577577
let path = this._sdRoutes.countEvent;
578578
return this.countQueryWrapper(query, path);
579579
}
580580

581581
/* Makes a exists query on Slicing Dice API
582582
*
583-
* @param (array) ids - the array of ids to check
583+
* @param (array) ids - the array of IDs to check
584+
* @param (string) table - the table to check for IDs
584585
*/
585-
existsEntity(ids) {
586-
if (ids.constructor != Array){
586+
existsEntity(ids, table = null) {
587+
if (ids.constructor != Array) {
587588
throw new errors.WrongTypeError("This method should receive an array as parameter");
588589
}
589-
if (ids.length > 100){
590+
if (ids.length > 100) {
590591
throw new errors.MaxLimitError("The query exists entity must have up to 100 ids.");
591592
}
592593
let path = this._sdRoutes.existsEntity;
593594
let query = {
594595
"ids": ids
595596
}
597+
if (table) {
598+
query["table"] = table
599+
}
596600
return this.makeRequest({
597601
path: path,
598602
reqType: "POST",

0 commit comments

Comments
 (0)