Skip to content

Commit aa4e135

Browse files
committed
Handle createField operation with a list of fields
1 parent 2cdab3d commit aa4e135

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/slicer.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,23 @@
518518
* @param (array) query - the query to send to Slicing Dice API
519519
*/
520520
createField(query){
521+
if (query instanceof Array) {
522+
let promises = [];
523+
for (let i = 0; i < query.length; i++) {
524+
promises.push(this.fieldCreate(query[i]));
525+
}
526+
527+
return Promise.all(promises);
528+
} else {
529+
return this.fieldCreate(query);
530+
}
531+
}
532+
533+
/* Create a field on Slicing Dice API
534+
*
535+
* @param (array) query - the query to send to Slicing Dice API
536+
*/
537+
fieldCreate(query) {
521538
let path = this._sdRoutes.field;
522539
let sdValidator = new FieldValidator(query);
523540
if (sdValidator.validator()){

0 commit comments

Comments
 (0)