db_schema.cljs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. (ns ^:nbb-compatible frontend.db-schema)
  2. (defonce version 1)
  3. (defonce ast-version 1)
  4. ;; A page is a special block, a page can corresponds to multiple files with the same ":block/name".
  5. (def ^:large-vars/data-var schema
  6. {:schema/version {}
  7. :ast/version {}
  8. :db/type {}
  9. :db/ident {:db/unique :db.unique/identity}
  10. :db/encrypted? {}
  11. :db/encryption-keys {}
  12. :recent/pages {}
  13. :block/type {}
  14. :block/uuid {:db/unique :db.unique/identity}
  15. :block/parent {:db/valueType :db.type/ref
  16. :db/index true}
  17. :block/left {:db/valueType :db.type/ref
  18. :db/index true}
  19. :block/collapsed? {:db/index true}
  20. ;; :markdown, :org
  21. :block/format {}
  22. ;; belongs to which page
  23. :block/page {:db/valueType :db.type/ref
  24. :db/index true}
  25. ;; reference blocks
  26. :block/refs {:db/valueType :db.type/ref
  27. :db/cardinality :db.cardinality/many}
  28. ;; referenced pages inherited from the parents
  29. :block/path-refs {:db/valueType :db.type/ref
  30. :db/cardinality :db.cardinality/many}
  31. ;; for pages
  32. :block/tags {:db/valueType :db.type/ref
  33. :db/cardinality :db.cardinality/many}
  34. ;; for pages
  35. :block/alias {:db/valueType :db.type/ref
  36. :db/cardinality :db.cardinality/many}
  37. ;; full-text for current block
  38. :block/content {}
  39. ;; todo keywords, e.g. "TODO", "DOING", "DONE"
  40. :block/marker {}
  41. ;; "A", "B", "C"
  42. :block/priority {}
  43. ;; block key value properties
  44. :block/properties {}
  45. ;; vector
  46. :block/properties-order {}
  47. ;; first block that's not a heading or unordered list
  48. :block/pre-block? {}
  49. ;; heading's level (the block must be a heading)
  50. :block/heading-level {}
  51. ;; scheduled day
  52. :block/scheduled {}
  53. ;; deadline day
  54. :block/deadline {}
  55. ;; whether blocks is a repeated block (usually a task)
  56. :block/repeated? {}
  57. :block/created-at {}
  58. :block/updated-at {}
  59. ;; page additional attributes
  60. ;; page's name, lowercase
  61. :block/name {:db/unique :db.unique/identity}
  62. ;; page's original name
  63. :block/original-name {:db/unique :db.unique/identity}
  64. ;; whether page's is a journal
  65. :block/journal? {}
  66. :block/journal-day {}
  67. ;; page's namespace
  68. :block/namespace {:db/valueType :db.type/ref}
  69. ;; block's file
  70. :block/file {:db/valueType :db.type/ref}
  71. ;; file
  72. :file/path {:db/unique :db.unique/identity}
  73. ;; only store the content of logseq's files
  74. :file/content {}
  75. :file/handle {}
  76. ;; :file/created-at {}
  77. ;; :file/last-modified-at {}
  78. ;; :file/size {}
  79. ;; :file/handle {}
  80. })
  81. (def retract-attributes
  82. #{
  83. :block/refs
  84. :block/path-refs
  85. :block/tags
  86. :block/alias
  87. :block/marker
  88. :block/priority
  89. :block/scheduled
  90. :block/deadline
  91. :block/repeated?
  92. :block/pre-block?
  93. :block/heading-level
  94. :block/type
  95. :block/properties
  96. :block/created-at
  97. :block/updated-at
  98. :block/warning
  99. }
  100. )
  101. ;;; use `(map [:db.fn/retractAttribute <id> <attr>] retract-page-attributes)`
  102. ;;; to remove attrs to make the page as it's just created and no file attached to it
  103. (def retract-page-attributes
  104. #{:block/created-at
  105. :block/updated-at
  106. :block/file
  107. :block/format
  108. :block/content
  109. :block/properties
  110. :block/alias
  111. :block/tags})