Caseblocks Logo

Bucket

Buckets

Class Methods

get(bucketId, caseTypeCode)

Retrieves a bucket from caseblocks supplying the id of the bucket and its case type code.

Caseblocks.Bucket.get(6, "bulk_uplifts").then(function(bucket) {
    log(bucket.attributes.name)
}).catch(function(err) {
    log("Failed to get bucket")
    fail(JSON.stringify(err))
})

stats()

Saves any changes made to the current document.

Caseblocks.Bucket.get(6, "bulk_uplifts").then(function(bucket) {
  log(bucket.attributes.name)
  bucket.stats().then(function(bucket_stats) {
    summary = bucket_stats["bucket_summary"]
    log("")
    log("Summary")
    log("=======")
    log("Total: " + summary.total)
    log("Last 24 hrs: " + summary.total_in_last_24_hours)
    log("")
    log("Stats")
    log("=====")
    stats = bucket_stats["bucket_stats"]
    for(i in stats) {
        log("  " + stats[i].term + ": " + stats[i].count)
    }
  }).catch(function(err) {
      log("Failed to get stats")
      fail(JSON.stringify(err))
  })
}).catch(function(err) {
    log("Failed to get bucket")
    fail(JSON.stringify(err))
})

cases(page, pageSize)

Retrieves cases contained in the bucket by page. Parameters are optional and page defaults to 0 and pageSize defaults to 10.

Caseblocks.Bucket.get(6, "bulk_uplifts").then(function(bucket) {
  log(bucket.attributes.name)
  bucket.cases(0,10).then(function(cases) {
    log("Found " + cases.length + " cases.")

    for(kase of cases) {
        log(kase.attributes.title)
    }

    exit(payload)
  }).catch(function(err) {
      log("Failed to get cases")
      fail(JSON.stringify(err))
  })
}).catch(function(err) {
    log("Failed to get bucket")
    fail(JSON.stringify(err))
})