-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dstore and positioning: tutorial outline #42
Comments
on a side note... X- headers are deprecated (http://tools.ietf.org/html/rfc6648) this reminded me to bring this up, i think dstore should stop using them. |
This looks good to me. I agree with Ben, that we should probably eliminate the X- prefix. I tend to think of "natural ordering" as being an order that is deterministic, controlled, and meaningful (when no sort order is defined), but I think that is more conceptual, and I think you basically mean the same thing since you said the server might opt out of that and use an optimization driven order. |
There is the possibility that I have been misusing the term "natural ordering". To me, "natural ordering" is when you add an item, placing it in a specific "spot" (could be at the end, at the beginning, or in the middle of a collection) and then expect it to find it exactly there when you query the collection without specifying a sorting option. With "server opting out" I mean this: with "natural ordering", the only meaningful way to do it is by adding a hidden field to the DB table (call it There are several ways of keeping natural ordering database-wide, but they are all quite expensive. With MySql, you end up with at least one mass-update per insert/update, to "make space" for example. So, the server might end up ignoring completely "natural ordering": if so, you can use Makes sense? Should I use a different term rather than "natural ordering"? (Which also means "ordering thing alphabetically so that it makes sense to humans") |
That is exactly what I had in mind with the term, sounds good. |
For the tutorial, does it make sense for me to post it here once it's written so that you guys can comment on it etc.? Or shall we close this issue and shall I email it to somebody when I am done? If so, who should I email it to? |
For now, I think you could submit this tutorial in a branch/PR under docs. Thank you for putting this together! |
Hi, OK will do! Merc. On 29 August 2014 04:31, Kris Zyp notifications@github.com wrote:
|
Hi people,
I am writing a tutorial to explain "placement" in dstore. This is aimed at people writing the server side of the story.
This is the "factual" outline of what I will explain. Can you please OK all this? I am 99.9% sure I didn't write anything stupid, but I would love to be double-checked!
I am also writing another tutorial where I explain pretty much every possible use-case scenario when using stores (cached, un-cached, with filtering on, etc.) explaining the (rare) cases where a refresh is needed. But that's a different story.
STORES AND POSITIONING
Natural ordering is where things are placed when querying without specifying sorting
Natural ordering should always exist for stores (although it could be switched off on server to optimise)
An item's placement is set by
beforeId
parameter input()
(existing and new elements)defaultNewToStart
is set totrue
(new elements)In Memory.js, the JS library has access to the store; so, when adding to Memory without
beforeId
, Memory checks for the store'sdefaultNewToStart
attribute to see where to place a new element. WhenbeforeId
is set tonull
, thendefaultNewToStart
is ignored and element is added at the end.In Rest.js, two headers are set depending on
put
'soptions.beforeId
and the store'sdefaultNewToStart
.beforeId
is set:null
,X-Put-Before
will be set tobeforeId
;null
,X-Put-Default-Position
will be set toend
.beforeId
is not set:X-Put-Default-Position
is set tostart
orend
(depending on the store'sdefaultNewToStart
).Note that
X-Put-Default-Position
is used BOTH ifbeforeId
isnull
(to make up for the inability to pass anything but a string via headers), AND for new elements wherebeforeId
is not set (to tell the server where to place the element in such a case, to make up for the fact that the server doesn't know what the client store's default is).The server doesn't know anything about the store; for positioning, two headers are used"
X-Put-Before
andX-Put-Default-Position
. If the server tracks natural ordering for the collection, it willX-Put-Before
is set. If so, will need to place the item thereX-Put-Default-Position
-- if it'send
, it will place things at the end. If it'sstart
, it will place the item as first. If it's a new element, and neither one of the headers is set, then will place at the end (the default)The text was updated successfully, but these errors were encountered: