command_result.js 752 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. /**
  3. * Creates a new CommandResult instance
  4. * @class
  5. * @param {object} result CommandResult object
  6. * @param {Connection} connection A connection instance associated with this result
  7. * @return {CommandResult} A cursor instance
  8. */
  9. var CommandResult = function(result, connection, message) {
  10. this.result = result;
  11. this.connection = connection;
  12. this.message = message;
  13. };
  14. /**
  15. * Convert CommandResult to JSON
  16. * @method
  17. * @return {object}
  18. */
  19. CommandResult.prototype.toJSON = function() {
  20. return this.result;
  21. };
  22. /**
  23. * Convert CommandResult to String representation
  24. * @method
  25. * @return {string}
  26. */
  27. CommandResult.prototype.toString = function() {
  28. return JSON.stringify(this.toJSON());
  29. };
  30. module.exports = CommandResult;