Skip to content

Commit

Permalink
dropped :on_duplicate_key option
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Andreev committed Apr 27, 2008
1 parent 84ec29b commit 817787d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
4 changes: 0 additions & 4 deletions lib/strokedb/views/view.rb
Expand Up @@ -18,10 +18,6 @@ module StrokeDB
# strategy determines whether to index HEADs or particular versions
# When :heads is used, previous versions are removed from the index.
"strategy" => "heads", # heads|versions

# what to do when the key is duplicated: add to list (append|prepend),
# overwrite or don't do anything ("skip").
"on_duplicate_key" => "append" # append|prepend|skip|overwrite
}

on_initialization do |viewdoc|
Expand Down
12 changes: 3 additions & 9 deletions meta/papers/overview/views.txt
Expand Up @@ -161,8 +161,7 @@ Scenarios:
2) View for indexing all the documents' versions by date.
If there're several versions per day, the latest one will be stored.

docs_by_date = View.find_or_create(:name => "docs_by_date",
:on_duplicate_key => :overwrite) do |view|
docs_by_date = View.find_or_create(:name => "docs_by_date") do |view|
def view.map(doc)
[ [ doc.created_at.to_date, doc.uuid ], doc ]
end
Expand All @@ -176,11 +175,7 @@ Scenarios:

When this index is updated, only particular versions are supplied
and nothing is removed from the list.

:on_duplicate_key => :overwrite tells, that only one revision
is stored per day. And this will be the latest revision, so you
can see what the document looked like at the end of the day.


To support both scenarios, we may introduce a simple switch
as a slot in the viewdoc:

Expand All @@ -198,8 +193,7 @@ SQL: select * from `versions` where `created_at` <= '2.days.ago' order by create

StrokeDB view:

docs_by_date = View.find_or_create(:name => "docs_by_date",
:on_duplicate_key => :overwrite) do |view|
docs_by_date = View.find_or_create(:name => "docs_by_date") do |view|
def view.map(doc)
[ [ doc.uuid, doc.created_at.to_date ], doc ]
end
Expand Down

0 comments on commit 817787d

Please sign in to comment.