Fork me on GitHub

Hi @tonsky, I saw that re-posh’s TODO example attaches a :app/type attribute to the entity. I had the same doubt as @eslachance, so I was wondering if that is a good way to have some kind of distinction of the kind (table) of the entity.


Actually what I think I'd like is... some examples of this. tbh I'm not sure it will work for me, I can accept that datascript might not be the right store for me.


Hmm. I'll have to study that a bit!


Give it a little time. This paradigm may feel a little odd at first coming from SQL, but it's actually much simpler and more flexible. It's actually a benefit that you only have to specify the attrs and can mix and match things, because it means you can get polymorphism for free, something that can get messy in SQL. And ultimately, it's less work for you to do up front. At the end of the day though, if you want your data to conform to some notion of tables or entity types, this is generally pretty easy to accomplish, and you get to be pretty thoughtful and in more control of how you do that.


You will see that is quite simple and what Tonsky said about everything being an entity hopefully will make sense 🙂


yes, you can maintain :app/type attr for every entity to be sure which is which. In practice, though, I found that it’s rarely needed


Cool, thank you. If I don’t use the :app/type attr, but I want to query all artists, how could I do that? In DataScript/Datomic we define ‘meaning’ to attrs, is that right? So we can share attrs among entities and it means that some other entity could use the :artist/name attr. If I query for entities with that attribute I will get other entities that are not of the ‘artist type’, right?


Is it right to think that for that to work I would have to attach an :app/type attr to artist so I can guarantee that I only get entities of that ‘type’?


usually there’s an attribute that’s unique to the entity though. Like :artist/id or smth. You can mix attrs between entities but it’s more like an exception than a commonplace practice


Right, I see. Thank you very much, Tonsky!