API Docs for: 2.2.2
Show:

File: lib/commands/kv/storebuckettypeprops.js

  1. 'use strict';
  2.  
  3. var inherits = require('util').inherits;
  4. var Joi = require('joi');
  5.  
  6. var StorePropsBase = require('./storepropsbase');
  7.  
  8. /**
  9. * Provides the StoreBucketTypeProps class, its builder, and its response.
  10. * @module KV
  11. */
  12.  
  13. /**
  14. * Command used to set the properties on a bucket type in Riak.
  15. *
  16. * As a convenience, a builder class is provided:
  17. *
  18. * var storeProps = new StoreBucketTypeProps.Builder()
  19. * .withBucketType('my-type')
  20. * .withAllowMult(true)
  21. * .build();
  22. *
  23. * See {{#crossLink "StoreBucketTypeProps.Builder"}}StoreBucketTypeProps.Builder{{/crossLink}}
  24. *
  25. * @class StoreBucketTypeProps
  26. * @constructor
  27. * @param {Object} options The properties to store
  28. * @param {String} [options.bucketType] The bucket type in riak. If not supplied 'default is used'
  29. * @param {Function} callback The callback to be executed when the operation completes.
  30. * @param {String} callback.err An error message. Will be null if no error.
  31. * @param {Boolean} callback.response the response from Riak. This will be true.
  32. * @param {Function} callback The callback to be executed when the operation completes.
  33. * @param {String} callback.err An error message. Will ne null if no error.
  34. * @param {Object} callback.response The response from Riak. This is an oject with all the bucket properties.
  35. * @param {Object} callback.data additional error data. Will be null if no error.
  36. * @extends StorePropsBase
  37. */
  38. function StoreBucketTypeProps(options, callback) {
  39. StorePropsBase.call(this, options, 'RpbSetBucketTypeReq', 'RpbSetBucketResp', callback);
  40. this.validateOptions(options, schema, { allowUnknown: true });
  41. }
  42.  
  43. inherits(StoreBucketTypeProps, StorePropsBase);
  44.  
  45. StoreBucketTypeProps.prototype.constructPbRequest = function() {
  46. var protobuf = StoreBucketTypeProps.super_.prototype.constructPbRequest.call(this);
  47. protobuf.setType(new Buffer(this.options.bucketType));
  48. return protobuf;
  49. };
  50.  
  51. /**
  52. * A builder for constructing StoreBucketTypeProps instances
  53. *
  54. * Rather than having to manually construct the __options__ and instantiating
  55. * a StoreBucketTypeProps directly, this builder may be used.
  56. *
  57. * var storeProps = new StoreBucketTypeProps.Builder()
  58. * .withAllowMult(true)
  59. * .build();
  60. *
  61. * @class StoreBucketTypeProps.Builder
  62. * @constructor
  63. * @extends StorePropsBase.Builder
  64. */
  65. function Builder() {
  66. StorePropsBase.Builder.call(this);
  67. this.precommit = [];
  68. this.postcommit = [];
  69. }
  70.  
  71. inherits(Builder, StorePropsBase.Builder);
  72.  
  73. var schema = Joi.object().keys({
  74. bucketType: Joi.string().default('default')
  75. });
  76.  
  77. /**
  78. * Construct a StoreBucketTypeProps instance.
  79. * @method build
  80. * @return {StoreBucketTypeProps}
  81. */
  82. Builder.prototype.build = function() {
  83. var cb = this.callback;
  84. delete this.callback;
  85. return new StoreBucketTypeProps(this, cb);
  86. };
  87.  
  88. module.exports = StoreBucketTypeProps;
  89. module.exports.Builder = Builder;
  90.