Fork me on GitHub
#asami
<
2022-02-25
>
lilactown04:02:28

how can I retract an entity?

quoll04:02:58

At this point, you need to delete all of its triples. Yes, I appreciate that isn't a great answer. I can certainly do something without a huge effort. But it doesn't exist because: • Asami is based on the OWA. This makes entity removal an unusual thing to do. Instead, removing individual statements usually makes more sense • Datomic (which introduced entities in this context) didn't have this function (I’m guessing it probably does now)

quoll04:02:36

This is easier than what I've been working on, so I could try it

lilactown06:02:38

I have 2 use cases that I think need retraction/deletion. I'm trying to model links between documents. right now, a document is keyed by the location on disk. e.g. {:db/ident "file:///Users/lilactown/note.md"} the operations I think I need retraction for are: • moving, which would delete the old node and create the new node • deletion, which would delete the node

quoll11:02:57

What do you mean by “moving”? Is it just changing the ident? If so, then that's just a special property for referring to the entity… you can update that property if you want

lilactown16:02:39

I am literally watching the file system and get events like

{:type :delete :path "/Users/lilactown/Code/dex/notes/foo"}
{:type :create :path "/Users/lilactown/Code/dex/notes/bar"}
when I rename a file. instead of trying to relate the two events, it's simpler for me to delete the entity that represented the foo doc and ingest the bar doc as a new entity

quoll17:02:34

Are these objects that show up in a stream, or are they things that you’re inserting into the database, and you’re seeing them as entities?

lilactown05:02:05

they're things that show up in a stream. I then load some metadata about them into the database related to their location and content

lilactown07:02:53

unrelated to deletion, I'm trying to add the links to each document as a vector. a link inside that vector would be an ident, e.g

{:db/ident "file:///Users/lilactown/Code/dex/notes/test-link.md"
 :uri "/Users/lilactown/Code/dex/notes/test-link.md",
 :type :local-file,
 :format "markdown",
 :links ["file:///Users/lilactown/Code/dex/notes/test.md"]}
however this doesn't seem to work well w.r.t. querying for "return the entities this document links to" etc.

quoll11:02:15

Is this because it's a linked list? The :tg/contains property was introduced to make that easy. Or you could make it a set instead of a vector (assuming you have the data in edn and not json)

lilactown16:02:03

I think I transact it as a seq. I'll see if changing the type makes it work better

lilactown16:02:43

yeah, changing it to a set worked. thanks!

quoll17:02:01

Yes, that’s a different structure. Data that is provided in a vector is treated as an “array”. You can see how these work and how to query the data https://github.com/threatgrid/asami/wiki/5.-Entity-Structure#arrays.

quoll17:02:14

But if you don’t care about the order, then sets are better

lilactown17:02:10

i don't think i need the order

quoll17:02:02

Then sets are the way to go.

quoll17:02:58

Once I get the optional schema in place, then I can make the presumption that an array is represented as a set when the associated attribute is single-cardinality

quoll17:02:14

but until then, I work on the datatypes

1