couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Views_for_Lotus_Geeks" by AlanBell
Date Sat, 02 Jan 2010 09:14:16 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Views_for_Lotus_Geeks" page has been changed by AlanBell.
http://wiki.apache.org/couchdb/Views_for_Lotus_Geeks?action=diff&rev1=3&rev2=4

--------------------------------------------------

  Form:"Task"
  Priority:"Medium"
  Subject:"Service Car"
- Created:"2009-12-31T19:51:22"
+ Created:"Wed Dec 4 00:00:00 2009"
  }}}
  {{{
  Form:"Task"
  Priority:"High"
  Subject:"Book restaurant for mum's birthday"
- Created:"2009-12-31T19:51:29"
+ Created:"Thu Dec 5 00:00:00 2009"
  }}}
  {{{
  Form:"Task"
  Priority:"Medium"
  Subject:"Return library books"
- Created:"2010-01-01T08:31:49"
+ Created:"Sat Jan 2 00:00:00 2010"
  }}}
- The first thing to notice is that the Created field is in a funny format for Notes, this
is ISO format datetime string, it sorts nicely as text and works well in Python and Javascript
and in fact pretty much every language but Lotusscript. We will come back to times and dates
in views later, but one thing worth mentioning is that you don't use the current time in a
couchdb view formula just like you don't use @now in a view selection or column formula for
exactly the same reason.
+ The first thing to notice is that the Created field is in a funny format for Notes, this
is a C format datetime string, it is human readable and works well in C, Python and Javascript.
It doesn't sort well as text, but can be converted to a sortable value in a javascript view
function. We will come back to times and dates in views later, but one thing worth mentioning
is that you don't use the current time in a couchdb view formula just like you don't use @now
in a view selection or column formula for exactly the same reason.
  
  In Notes we might display the documents in a flat view (categorisation comes later)
  
@@ -32, +32 @@

  {{{
  Select form="Task"
  }}}
- And view columns would be Priority (sorted), Created (sorted) and Subject
+ And view columns would be Priority (sorted), Created (sorted, hidden) and Subject
  ||<tablewidth="599px" tableheight="227px"style="font-weight: bold;">Priority ||<style="font-weight:
bold;">Created ||<style="font-weight: bold;">Subject ||
- ||High ||2009-12-31T19:51:29 ||Book restaurant for mum's birthday ||
+ ||High || ||Book restaurant for mum's birthday ||
- ||Medium ||2009-12-31T19:51:22 ||Service Car ||
+ ||Medium || ||Service Car ||
- ||Medium ||2010-01-01T08:31:49 ||Return library books ||
+ ||Medium || ||Return library books ||
  
  
  
@@ -46, +46 @@

  {{{
  function(doc) {
      if(doc.form=="Task"){
-         emit([doc.priority,doc.created],[doc.priority,doc.created,doc.subject])
+         emit([doc.priority,new Date.parse(doc.created)],[doc.priority,doc.subject])
      }
  }
  }}}
  The selection formula in notes ends up in the javascript if statement, note the double "=="
which is the operator to test for equality. In javascript a single "=" is the assignment operator
(like := in formula language) if you use a single "=" then it would return all documents,
with their form fields assigned to "Task".
  
- The emit function has two parameters, the keys and the values. Keys are kind of like categories
or sorted columns. Values are kind of like column values. If you want you can think of it
like a view with hidden sorted columns as the keys followed by a set of unsorted columns -
the values.
+ The emit function has two parameters, the keys and the values. Keys are kind of like categories
or sorted columns. Values are kind of like column values. If you want you can think of it
like a view with hidden sorted columns as the keys followed by a set of unsorted columns -
the values. In order to get the dates sorting correctly we are creating parsing the string
with javascript to create a number of milliseconds from January 1st 1970
  

Mime
View raw message