accountSchema.js 952 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const moduleManager = require("../../../index");
  2. const mongoModule = moduleManager.modules["mongo"];
  3. const accountSchemaModule = moduleManager.modules["accountSchema"];
  4. module.exports = {
  5. "getLatest": cb => {
  6. accountSchemaModule.getLatest().then(schema => {
  7. cb({
  8. status: "success",
  9. schema
  10. });
  11. }).catch(err => {
  12. cb({
  13. status: "failure"
  14. });
  15. });
  16. },
  17. "getAll": cb => {
  18. accountSchemaModule.getAll().then(schemas => {
  19. cb({
  20. status: "success",
  21. schemas
  22. });
  23. }).catch(err => {
  24. cb({
  25. status: "failure"
  26. });
  27. });
  28. },
  29. "getById": (cb, schemaId) => {
  30. accountSchemaModule.getById(schemaId).then(schema => {
  31. cb({
  32. status: "success",
  33. schema
  34. });
  35. }).catch(err => {
  36. cb({
  37. status: "failure"
  38. });
  39. });
  40. },
  41. "import": (cb, name) => {
  42. accountSchemaModule.import(name).then(() => {
  43. cb({
  44. status: "success"
  45. });
  46. }).catch(err => {
  47. cb({
  48. status: "failure"
  49. });
  50. });
  51. }
  52. }