db.js

  1. import Loki from 'lokijs';
  2. /**
  3. * LokiJS databases.
  4. *
  5. * @namespace lokijs
  6. */
  7. const db = new Loki('lokijs.db');
  8. /**
  9. * LokiJS database that holds the Items of a Sitemap.
  10. *
  11. * @memberof lokijs
  12. */
  13. export const itemsOfSitemapDb = db.addCollection('sitemaps', {
  14. exact: ['name', 'lastupdate', 'items'],
  15. indices: ['name'],
  16. autoload: false,
  17. autosave: false,
  18. autosaveInterval: 10000
  19. });
  20. /**
  21. * LokiJS database that holds the list of Sitemaps.
  22. * Fetched from: /rest/sitemaps
  23. *
  24. * @memberof lokijs
  25. */
  26. export const sitemapsListDb = db.addCollection('sitemapsList', {
  27. exact: ['name', 'lastupdate', 'json'],
  28. indices: ['name'],
  29. autoload: false,
  30. autosave: false,
  31. autosaveInterval: 10000
  32. });
  33. /**
  34. * LokiJS database that holds the list of Pages.
  35. * Fetched from: /rest/ui/components/ui:page
  36. *
  37. * @memberof lokijs
  38. */
  39. export const pagesListDb = db.addCollection('pagesList', {
  40. exact: ['name', 'lastupdate', 'json'],
  41. indices: ['name'],
  42. autoload: false,
  43. autosave: false,
  44. autosaveInterval: 10000
  45. });
  46. /**
  47. * LokiJS database that holds all Items.
  48. * Fetched from: /rest/items
  49. *
  50. * @memberof lokijs
  51. */
  52. export const itemsListDb = db.addCollection('itemsList', {
  53. exact: ['name', 'lastupdate', 'json'],
  54. indices: ['name'],
  55. autoload: false,
  56. autosave: false,
  57. autosaveInterval: 10000
  58. });
  59. /**
  60. * LokiJS database that holds the Sitemaps allowed for a user.
  61. *
  62. * @memberof lokijs
  63. */
  64. export const sitemapsForUserDb = db.addCollection('sitemapsForUser', {
  65. exact: ['name', 'lastupdate', 'sitemaps'],
  66. indices: ['name'],
  67. autoload: false,
  68. autosave: false,
  69. autosaveInterval: 10000
  70. });
  71. /**
  72. * LokiJS database that holds the Pages allowed for a user.
  73. *
  74. * @memberof lokijs
  75. */
  76. export const pagesForUserDb = db.addCollection('pagesForUser', {
  77. exact: ['name', 'lastupdate', 'pages'],
  78. indices: ['name'],
  79. autoload: false,
  80. autosave: false,
  81. autosaveInterval: 10000
  82. });
  83. /**
  84. * LokiJS database that holds the Items allowed for a user.
  85. *
  86. * @memberof lokijs
  87. */
  88. export const itemsForUserDb = db.addCollection('itemsForUser', {
  89. exact: ['name', 'lastupdate', 'items'],
  90. indices: ['name'],
  91. autoload: false,
  92. autosave: false,
  93. autosaveInterval: 10000
  94. });