Skip to content

Commit 43cf418

Browse files
Update countEntityTotal method and README example
1 parent a76f9dd commit 43cf418

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ client.existsEntity(ids).then((resp) => {
308308
```
309309

310310
### `countEntityTotal()`
311-
Count the number of inserted entities. This method corresponds to a [GET request at /query/count/entity/total](http://panel.slicingdice.com/docs/#api-details-api-endpoints-get-query-count-entity-total).
311+
Count the number of inserted entities. This method corresponds to a [POST request at /query/count/entity/total](http://panel.slicingdice.com/docs/#api-details-api-endpoints-get-query-count-entity-total).
312312

313313
#### Request example
314314

@@ -320,7 +320,13 @@ const client = new SlicingDice({
320320
readKey: 'READ_KEY'
321321
}, usesTestEndpoint = true);
322322

323-
client.countEntityTotal().then((resp) => {
323+
const tables = {
324+
"tables": [
325+
"default"
326+
]
327+
};
328+
329+
client.countEntityTotal(tables).then((resp) => {
324330
console.log(resp);
325331
}, (err) => {
326332
console.error(err);

src/slicer.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,20 @@
551551
let sdValidator = new QueryCountValidator(query);
552552
return this.countQueryWrapper(query, path);
553553
}
554-
555-
/* Makes a total query on Slicing Dice API */
556-
countEntityTotal() {
554+
555+
/* Makes a total query on Slicing Dice API
556+
*
557+
* @param (array) tables - the tables in which the total query will be performed
558+
*/
559+
countEntityTotal(tables = {}) {
560+
if(!tables){
561+
tables = {};
562+
}
557563
let path = this._sdRoutes.countEntityTotal;
558564
return this.makeRequest({
559565
path: path,
560-
reqType: "GET",
566+
reqType: "POST",
567+
data: tables,
561568
levelKey: 0
562569
})
563570
}

0 commit comments

Comments
 (0)