A model is a type, a table on the back end and its rules. The page writes it with no server fn: the write shows at once, is sent in order, and is taken back if the back end says no. A live value over a find is sent the rows a write changed, never the list again.
A write shows at oncePgNote.add in the page puts the row the back end will keep in every live list at once, dimmed while pending(row) is true; the answer's row takes its place, the same node. Make the line slow (the back end waits a second before each write) to see it; switch on wait for it to write with confirmed.
a slow linewrites are kept at once
wait for itNote.add(…)?
live notes
No notes yet.
With wait on, nothing shows and the button stays pending until the answer: pending(add) is the action's. With it off, pending(add) is over at once: dim the row, not the button.
Refused, and taken backA server before hook may say no where the page could not know: here, to a note with the word refuse in it. The row shows at once, then goes; the else beside the write runs when the answer arrives. What the action did after that line stays done.
what happened
Press it (with the slow line on, watch it show and go).
Two lists, one findEach list is a live value of its own over the same PgNote.find. The list is sent once when it is asked for; after that a write sends each the row it changed (a few hundred bytes), or only its key when a row goes, never the list again. Add, tick and remove above, or in another window: both lists follow.
one live value
No notes yet.
another, the same find
No notes yet.
put and incT.put(row, changes) changes the row there by its key, or adds row: one turn of the database, so two callers never both add it. inc(n) is this much more than it is. A page's set with inc shows at once; a page's put waits, since only the back end knows which it will be.
likes0
Rows taken togetherT.count(f, {by}) and T.sum(f, field, {by, order, limit}) are one GROUP BY statement each, asked in a server fn (the back end's alone: a page reads rows). Place a few orders, then count.