Anna-Team / AnnaDB

Developer-first database
Apache License 2.0
56 stars 4 forks source link

Feature Request: Conditional Operations #16

Open amaster507 opened 1 year ago

amaster507 commented 1 year ago

I am thinking of a use case for this database, and one point is building a layer of abstration on top of this underlying simplicity. One of my goals is to reduce the data footprint by storing data with singularity. In order to do that though, I would need to be able to do a single operation where I have a value and I want to either insert it as a new item and return the item id, or if it already exists, I want to return the item id of the existing item and not insert it.

Here is what that might look like in TySON:

collection|strings|:q[
  find[
    eq{root:s|foo|}
  ],
  if[
    lt{count:n|1|},
    insert[s|foo|]
  ]
]