Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. "use strict"
  2.  
  3. const Interface = require("../interface")
  4. const {symbols} = require("../recommended")
  5.  
  6. class Adapter_Interface extends Interface {
  7. get [symbols.INTERFACE]() {
  8. return {
  9. /**
  10. * The connect function takes one argument of
  11. * the config to connect to the database.
  12. *
  13. * It should return a Promise.
  14. *
  15. * @param {Object} config to pass to the underlying adapter.
  16. * @return {Promise} promise to continue execution.
  17. */
  18. connect: 1,
  19.  
  20. /**
  21. * The disconnect function disconnects from the database and
  22. * throws away any/all data it has in memory.
  23. *
  24. * It should return a Promise.
  25. *
  26. * @param {Object} config to pass to the underlying adapter.
  27. * @return {Promise} promise to continue execution.
  28. */
  29. disconnect: 0,
  30.  
  31. /**
  32. * The describe function returns information on
  33. * the contents of the database, returning Table names,
  34. * columns, types of your columns and indexes.
  35. *
  36. * It should return a Promise.
  37. *
  38. * @param {Object} config to pass to the underlying adapter.
  39. * @return {Promise} promise to continue execution.
  40. */
  41. describe: 0,
  42.  
  43. /**
  44. * The find function finds rows and documents
  45. * within the database underneath. The function
  46. * takes two arguments which are the search criteria
  47. * to find within the dataset and options to pass such
  48. * as limit.
  49. *
  50. * Returns an instance of the QueryTranslator.
  51. *
  52. * Once executed, resolved promise will receive an Array
  53. * of results from the database.
  54. *
  55. * @param {Object} search_criteria to find data on.
  56. * @param {Object} options to pass to the adapter.
  57. * @return {QueryTranslator} query_translator for continueing query build or execution.
  58. */
  59. find: 2,
  60.  
  61. /**
  62. * The update function updates the database
  63. * and takes 2 arguments, the first is the search
  64. * criteria and the second is the data to write.
  65. *
  66. * Once executed, resolved promise will receive an Array
  67. * of updated results from the database.
  68. *
  69. * @param {Object} search criteria to update on.
  70. * @param {Object} values values to set on the found records.
  71. * @param {Object} options to pass to the adapter
  72. * @return {Promise} promise in either a rejected or resolved state.
  73. */
  74. update: 3,
  75.  
  76. /**
  77. * The delete function deletes rows and documents
  78. * within the database underneath. The function
  79. * takes two arguments which are the search criteria
  80. * to find within the dataset and options to pass such
  81. * as limit.
  82. *
  83. * Once executed, resolved promise will receive an Array
  84. * of deleted results from the database.
  85. *
  86. * @param {Object} search_criteria to find data on.
  87. * @param {Object} options to pass to the adapter.
  88. * @return {Promise} promise in either a rejected or resolved state.
  89. */
  90. delete: 2
  91. }
  92. }
  93. }
  94.  
  95. module.exports = Adapter_Interface
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement