asami

lilactown 2022-02-25T04:01:28.402599Z

how can I retract an entity?

quoll 2022-02-25T04:09:58.905549Z

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)

quoll 2022-02-25T04:10:36.071959Z

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

lilactown 2022-02-25T06:54:38.718569Z

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

quoll 2022-02-25T11:18:57.928629Z

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

lilactown 2022-02-25T16:25:39.634539Z

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

quoll 2022-02-25T17:41:34.504849Z

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?

lilactown 2022-02-26T05:29:05.948429Z

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

lilactown 2022-02-25T07:10:53.090139Z

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.

quoll 2022-02-25T11:21:15.809439Z

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)

lilactown 2022-02-25T16:22:03.116679Z

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

lilactown 2022-02-25T16:27:43.804449Z

yeah, changing it to a set worked. thanks!

quoll 2022-02-25T17:21:01.064809Z

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.

quoll 2022-02-25T17:21:14.877379Z

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

lilactown 2022-02-25T17:25:10.743929Z

i don't think i need the order

quoll 2022-02-25T17:42:02.720489Z

Then sets are the way to go.

quoll 2022-02-25T17:42:58.935509Z

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

quoll 2022-02-25T17:43:14.114529Z

but until then, I work on the datatypes

👍🏻 1