Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Do arrows really inc and dec? #2

Open
michielbdejong opened this issue Jun 23, 2021 · 6 comments
Open

Do arrows really inc and dec? #2

michielbdejong opened this issue Jun 23, 2021 · 6 comments

Comments

@michielbdejong
Copy link

In Chrome, the numeric inputs have small inc/dec arrow buttons. Arrow-up and arrow-down also work.
From https://github.com/m-ld/m-ld-web-starter/blob/main/form.js#L274 and from the console log:

DatasetEngine write request {"@delete":{"@id":"a0380210","stock":"5"},"@insert":{"@id":"a0380210","stock":"4"}}

it seems you are writing these as strings?

I tried this by hitting Ctrl-C on the node index.js process, then editing in two tabs, and starting node index.js again. Both clones then see "Someone else is editing this value!".

So then maybe this is not a good example of how to use m-ld properly? Maybe given that m-ld treats these values as string, change them to "text" inputs in form.html?

@gsvarovsky
Copy link
Member

Great catch. As it happens, here the app is just writing strings. m-ld does actually respect the original data type. So yeah, we're using it badly. We could change the app to write numbers instead.

Note that this is not related to the conflict scenario you noticed in #3, which will still happen with numbers. Every 'increment' or 'decrement' is actually just a 'delete the old value and insert the new one'. So there are no special 'counter' semantics going on here.

@michielbdejong
Copy link
Author

michielbdejong commented Jun 23, 2021

Ah, but does m-ld offer counters? Where can I read more about that?

@gsvarovsky
Copy link
Member

gsvarovsky commented Jun 23, 2021

There's nothing built-in with basic counting semantics, no; like everyone has a bell and I just want to know the number of dings that there have been. There is a way to do this using constraints, but it hasn't been a priority so far.

That's probably because something like 'likes' is not really a counter – it's a Set of people who like something, with the size of the set being displayed.

In this case each of the numeric fields in this form is probably not a counter either. It might be a single-valued field with a 'max-value-wins' semantic, as we've discussed in your repo.

@gsvarovsky
Copy link
Member

I added a branch with the single-valued constraint on the quantity field, for illustration:

https://github.com/m-ld/m-ld-web-starter/compare/single-valued-quantity

Note the constraints API is experimental. I want to align more closely with RDF ways of doing schemas/shapes/ontologies, and in particular, have the definitions in the data rather than in the configuration.

@michielbdejong
Copy link
Author

Great! So what is the rule now in that branch, highest quantity wins? Or latest wall-clock time?

@gsvarovsky
Copy link
Member

Max value wins, by default. Other strategies could be added!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants