This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-10
Channels
- # announcements (4)
- # beginners (111)
- # calva (12)
- # cider (10)
- # cljdoc (1)
- # cljs-dev (7)
- # cljsrn (4)
- # clojure (38)
- # clojure-houston (1)
- # clojure-serbia (3)
- # clojure-spec (22)
- # clojure-uk (26)
- # clojurescript (4)
- # cursive (1)
- # data-science (1)
- # datomic (12)
- # klipse (1)
- # off-topic (25)
- # pathom (9)
- # protorepl (3)
- # quil (4)
- # shadow-cljs (43)
- # tools-deps (24)
We are testing datomic-cloud and are planning to start using it soon. We have a business SaaS product and currently use a single multi-tenant database. The question is, is there any recommended architecture for multi-tenant apps? Single database, multiple databases?
I had success with the following architecture: design a schema for multi-tenancy but place each tenant in a separate database. We also had an admin or account database that served as a catalog of accounts.
By designing the schema for multi-tenants, we were able to more directly handle new business requirements around free-tier accounts (all of those went into a single db) and we anticipated that would be easier to handle requirements around subaccounts
Let me see if I understand what you are saying. You kept an :account/id
attribute for every record that needed that, but instead of using one db you used multiple dbs?
I was considering using different db for each tenant (account) to be able to get rid of the :account/id
in every single record. So I wanted to know if there was some hard limit on the number of dbs you can create in datomic or if it’s not a best practice, etc
Yes, I kept :account/id
and it (almost always) had the same value within the db.
I don't believe there is a hard limit on number of dbs. However, Stu once said that an implementation detail kept multiple dbs from being as performant at current transact
operations as it theoretically could be. I suggest you contact Datomic support if you are concerned about high throughput concurrent transactions across dbs.
Beginner question... using a datalog query, how would I assert the value is non-nil? [?e :my/attr ???]
You can't have nil
values in Datomic so you want to assert that an attribute exists for the entity which you can do with [?e :my/attr]
.
you can also use the missing?
predicate: https://docs.datomic.com/on-prem/query.html#missing and https://docs.datomic.com/cloud/query/query-data-reference.html#missing
thank you both!