datomic

modelling multiple many-to-many relationships in datomic

余生颓废 提交于 2019-12-03 06:11:32
Maybe I'm still thinking sql but I'm having trouble writing the datomic schema for a simple blog. I don't really understand the :db/cardinality attribute and what it means. In terms of this type of system, how do we model these relationships The system supports multiple users Each user may have many categories Each user may have many articles Each category may have many users Each category may have many articles Each article may have many comments Each comment has one user Look at the following diagram and read the full code sample (schema, sample data and queries) at https://gist.github.com

Get all fields from a Datomic entity

老子叫甜甜 提交于 2019-12-03 05:41:47
问题 The 'Embedded' section of the Datomic Queries and Rules document says: Query languages like SQL are oriented around a client-server model where, in a single conversaton, you are going to have to both: Answer your fundamental question, e.g. who bought socks this month. Recover any additional information required for reporting and processing, e.g. what are their names and email addresses. The latter is not really a query, it is just a mechanical navigation to related information. While I

How does the storage backend influence Datomic?

我只是一个虾纸丫 提交于 2019-12-03 04:44:15
问题 How should I pick the backend storage service for Datomic? Is it a matter of preference to select, say, DynamoDB instead of Postgres, or does each option have different tradeoffs? If so, what are they? 回答1: Storage Services Requirements Datomic' storage services should generally meet 3 requirements: Implement key-value store semantics : efficient read/write access using indexed keys’ values Support consistent reads . e.g. read your own writes. Ideally, no-contention/lock-free reads. Support

Get all fields from a Datomic entity

纵然是瞬间 提交于 2019-12-02 18:07:33
The 'Embedded' section of the Datomic Queries and Rules document says: Query languages like SQL are oriented around a client-server model where, in a single conversaton, you are going to have to both: Answer your fundamental question, e.g. who bought socks this month. Recover any additional information required for reporting and processing, e.g. what are their names and email addresses. The latter is not really a query, it is just a mechanical navigation to related information. While I appreciate how the orthogonality of the two different mentioned aspects is honored, I think I'll often need

How does the storage backend influence Datomic?

ぐ巨炮叔叔 提交于 2019-12-02 17:56:09
How should I pick the backend storage service for Datomic? Is it a matter of preference to select, say, DynamoDB instead of Postgres, or does each option have different tradeoffs? If so, what are they? Storage Services Requirements Datomic' storage services should generally meet 3 requirements: Implement key-value store semantics : efficient read/write access using indexed keys’ values Support consistent reads . e.g. read your own writes. Ideally, no-contention/lock-free reads. Support conditional puts . e.g. optimistic locking + snapshot isolation. Datomic uses storages services to store

How can I list all user-created attributes?

China☆狼群 提交于 2019-12-02 04:56:02
问题 I tried to find all user-created attributes with the code below and it returns many other default attributes, like db/unique and fressian/tag . I'd like to get a set without them, so I was wondering if there is a better way to get it than filtering out the attributes by their prefixes. Thanks (q {:find '[?ident] :where '[[:db.part/db :db.install/attribute ?p] [?p :db/ident ?ident]]} db) or (filter (partial instance? datomic.db.Attribute) (:elements (p/db))) 回答1: One way to do it is to white

How can I list all user-created attributes?

老子叫甜甜 提交于 2019-12-02 03:10:16
I tried to find all user-created attributes with the code below and it returns many other default attributes, like db/unique and fressian/tag . I'd like to get a set without them, so I was wondering if there is a better way to get it than filtering out the attributes by their prefixes. Thanks (q {:find '[?ident] :where '[[:db.part/db :db.install/attribute ?p] [?p :db/ident ?ident]]} db) or (filter (partial instance? datomic.db.Attribute) (:elements (p/db))) One way to do it is to white/black list the namespaces you want to filter out or include. Note there's no difference between some of

is there a canonical way to grab all idents from a particular datomic namespace?

别来无恙 提交于 2019-12-01 07:02:20
say I had :user/name and :user/gender installed as datomic schema. (pprint (d/q '[:find ?ident :where [?e :db/ident ?ident] [_ :db.install/attribute ?e]] (d/db conn))) finds all the db.install/attributes #{[:db/code] [:user/gender] [:fressian/tag] [:db/unique] [:user/name] [:db/fn] [:db/noHistory] [:db/fulltext] [:db/lang] [:db/valueType] [:db/doc] [:db/isComponent] [:db.install/function] [:db/cardinality] [:db/txInstant] [:db/index]} however, I only want to list items in the :user namespace [:user/gender] [:user/name] what should I add to the query or is there a function that does it

Find entities whose ref-to-many attribute contains all elements of input

☆樱花仙子☆ 提交于 2019-12-01 06:30:36
Suppose I have entity entry with ref-to-many attribute :entry/groups . How should I build a query to find entities whose :entry/groups attribute contains all of my input foreign ids? Next pseudocode will illustrate my question better: [2 3] ; having this as input foreign ids ;; and having these entry entities in db [{:entry/id "A" :entry/groups [2 3 4]} {:entry/id "B" :entry/groups [2]} {:entry/id "C" :entry/groups [2 3]} {:entry/id "D" :entry/groups [1 2 3]} {:entry/id "E" :entry/groups [2 4]}] ;; only A, C, D should be pulled Being new in Datomic/Datalog, I exhausted all options, so any help

Find entities whose ref-to-many attribute contains all elements of input

走远了吗. 提交于 2019-12-01 05:32:06
问题 Suppose I have entity entry with ref-to-many attribute :entry/groups . How should I build a query to find entities whose :entry/groups attribute contains all of my input foreign ids? Next pseudocode will illustrate my question better: [2 3] ; having this as input foreign ids ;; and having these entry entities in db [{:entry/id "A" :entry/groups [2 3 4]} {:entry/id "B" :entry/groups [2]} {:entry/id "C" :entry/groups [2 3]} {:entry/id "D" :entry/groups [1 2 3]} {:entry/id "E" :entry/groups [2 4