query-result.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2015-present, Vitaly Tomilov
  3. *
  4. * See the LICENSE file at the top-level directory of this distribution
  5. * for licensing information.
  6. *
  7. * Removal or modification of this copyright notice is prohibited.
  8. */
  9. /**
  10. * @enum {number}
  11. * @alias queryResult
  12. * @readonly
  13. * @description
  14. * **Query Result Mask**
  15. *
  16. * Binary mask that represents the number of rows expected from a query method,
  17. * used by generic {@link Database#query query} method, plus {@link Database#func func}.
  18. *
  19. * The mask is always the last optional parameter, which defaults to `queryResult.any`.
  20. *
  21. * Any combination of flags is supported, except for `one + many`.
  22. *
  23. * The type is available from the library's root: `pgp.queryResult`.
  24. *
  25. * @see {@link Database#query Database.query}, {@link Database#func Database.func}
  26. */
  27. const queryResult = {
  28. /** Single row is expected, to be resolved as a single row-object. */
  29. one: 1,
  30. /** One or more rows expected, to be resolved as an array, with at least 1 row-object. */
  31. many: 2,
  32. /** Expecting no rows, to be resolved with `null`. */
  33. none: 4,
  34. /** `many|none` - any result is expected, to be resolved with an array of rows-objects. */
  35. any: 6
  36. };
  37. module.exports = {queryResult};